Educational Codeforces Round 106 (Rated for Div. 2) A

A. Domino on Windowsill

原题链接

题面

You have a board represented as a grid with 2×n cells.

The first k1 cells on the first row and first k2 cells on the second row are colored in white. All other cells are colored in black.

You have w white dominoes (2×1 tiles, both cells are colored in white) and b black dominoes (2×1 tiles, both cells are colored in black).

You can place a white domino on the board if both board’s cells are white and not occupied by any other domino. In the same way, you can place a black domino if both cells are black and not occupied by any other domino.

Can you place all w+b dominoes on the board if you can place dominoes both horizontally and vertically?

Input

The first line contains a single integer t (1≤t≤3000) — the number of test cases.

The first line of each test case contains three integers n, k1 and k2 (1≤n≤1000; 0≤k1,k2≤n).

The second line of each test case contains two integers w and b (0≤w,b≤n).

Output

For each test case, print YES if it’s possible to place all w+b dominoes on the board and NO, otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

Example

Input

5
1 0 1
1 0
1 1 1
0 0
3 0 0
1 3
4 3 1
2 2
5 4 3
3 1

Output

NO
YES
NO
YES
YES

Note

n the first test case, n=1, k1=0 and k2=1. It means that 2×1 board has black cell (1,1) and white cell (2,1). So, you can’t place any white domino, since there is only one white cell.

In the second test case, the board of the same size 2×1, but both cell are white. Since w=0 and b=0, so you can place 0+0=0 dominoes on the board.

In the third test case, board 2×3, but fully colored in black (since k1=k2=0), so you can’t place any white domino.

In the fourth test case, cells (1,1), (1,2), (1,3), and (2,1) are white and other cells are black. You can place 2 white dominoes at positions ((1,1),(2,1)) and ((1,2),(1,3)) and 2 black dominoes at positions ((1,4),(2,4)) ((2,2),(2,3)).

题意

两个相邻且相同颜色的格子可以放置一个多米诺骨牌,简而言之就是一个面积为2的白色或者黑色区域就可以占据一个牌的位置,求所给的区域能否放置样例足够的骨牌

思路

求出区域能够能够放置最多的白色或黑色骨牌,是否大于或等于所给的骨牌。因为是2*n的面积,我们可以看出白色面积就是k1+k2,黑色面积就是2n-k1-k2

代码如下

#include <iostream>
 
using namespace std;
 
 
 
int main(void)
{
    int t;
    cin >> t;
    while(t--)
    {
        int n,k1,k2,w,b;
        cin >> n >> k1 >> k2;
        cin >> w >> b;
        
        int sumw = k1 + k2,sumb = 2*n - sumw;//白色黑色面积
        
        int w1,b1;
        w1 = sumw / 2;//白色可以放置的最大数
        b1 = sumb / 2;//黑色可以放置的最大数
        if(w1>=w&&b1>=b)cout << "yes" << endl;//判断是否满足条件
        else cout << "no" << endl;
    }
    
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的转变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值