CodeForces839B Game of the Rows
来源:互联网 发布:登山杖淘宝 编辑:程序博客网 时间:2024/05/24 01:28
写的有点丑,,,
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<set>#include<stack>#include<queue>#include<ctype.h>#include<vector>#include<algorithm>// cout << " === " << endl;using namespace std;typedef long long ll;const int maxn = 100 + 7, INF = 0x3f3f3f3f, mod = 1e9+7;int n, k, n1, n2;int x;int main() { scanf("%d%d", &n, &k); n1 = n, n2 = n * 2; int x1 = 0, x2 = 0; for(int i = 0; i < k; ++i) { scanf("%d", &x); while(x > 0) { if(x >= 3) { if(n1) { x -= 4; n1--; } else if(n2 >= 2){ x -= 4; n2 -= 2; } else { cout << "NO" << endl; return 0; } } if(x == 1) { x1++; x -= 1; } else if(x == 2) { if(n2) { n2--; x -= 2; } else { x2++; x -= 2; } } } } //cout << x1 << " ++ " << x2 << endl; if(x2 > 0) { if(x2 > n1) { x2 -= n1; x1 += 2 * x2; x1 -= n1; n1 = 0; } else { n1 -= x2; x1 -= x2; } } if(x1 <= 0) { cout << "YES" << endl; return 0; } else if(2 * n1 + n2 >= x1){ cout << "YES" << endl; return 0; } else { cout << "NO" << endl; return 0; } return 0;}
阅读全文
1 0
- Codeforces839B Game of the Rows
- CodeForces839B Game of the Rows
- Game of the Rows
- Game of the Rows
- cf839B Game of the rows
- Game of the Rows CodeForces
- Game of the Rows CodeForces
- codeforces 839 B Game of the Rows
- Codeforces 839B-Game of the Rows
- B. Game of the Rows(贪心)
- Codeforces 839B Game of the Rows (贪心)
- 839B Game of the Rows(水,思维,贪心)
- Codeforces 839 B. Game of the Rows (贪心)
- Codeforce 839 -- B Game of the Rows 【思维 + 贪心】
- Arya and Bran & Game of the Rows & Multiple Clocks
- Codeforces Round #428 (Div. 2) Game of the Rows (思维)
- Codeforces Round #428 (Div. 2) B. Game of the Rows
- Codeforce-839B Game of the Rows 思维
- Protostuff序列化
- 基于hadoop2.2的namenode与SecondaryNameNode分开配置在不同的计算机
- JAVA中上转型对象的详细解释
- 如何相互转换逗号分隔的字符串和List (Java程序员日记 2015/03/06)
- 比较全面的正则表达式使用教程
- CodeForces839B Game of the Rows
- Cookies 和 Session的区别
- Java设计模式
- mysql-python的安装问题
- 大数据和人工智能的相关比赛
- java web 开发需要掌握哪些技术(转载)
- 【代码笔记】iOS-获得现在的时间(2015-09-11)
- Spring异步方法简易实现
- 详解C# Tuple VS ValueTuple(元组类 VS 值元组)