Codeforces 839B - Game of the Rows
839B - Game of the Rows
思路:先放4个的,然后再放2个的,最后再放1个的。
代码:
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset((a),(b),sizeof(a)) int a[105];int main() {int n,k;cin>>n>>k;int c2=n*2; int c4=n;for(int i=1;i<=k;i++)cin>>a[i];for(int i=1;i<=k;i++){int c=min(c4,a[i]/4);c4-=c;a[i]-=c*4;}c2+=c4;//剩下的4个连在一起的也可以放2个的 for(int i=1;i<=k;i++){int c=min(c2,a[i]/2);c2-=c;a[i]-=c*2;}int t=c2+c4;//原来的4个连在一起的放二个的时候只放了一半,而且放了一半也可能没放满 for(int i=1;i<=k;i++){t-=a[i];}if(t<0)cout<<"NO"<<endl;else cout<<"YES"<<endl;return 0; }
转载于:https://www.cnblogs.com/widsom/p/7353437.html
Codeforces 839B - Game of the Rows相关推荐
- Codeforces 题目合集+分类+代码 【Updating...】【361 in total】
961A - Tetris 模拟 ...
- C - Multiplication Table CodeForces - 448D
C - Multiplication Table CodeForces - 448D 题目: Problem Description Bizon the Champion isn't just cha ...
- (CodeForces 548B 暴力) Mike and Fun
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...
- 【Codeforces】 Round #374 (Div. 2)
Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...
- Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard in ...
- Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题
A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...
- Codeforces Codeforces Round #319 (Div. 2) A. Multiplication Table 水题
A. Multiplication Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/57 ...
- cf1555C Coin Rows
cf1555C Coin Rows 题意: 有一个两行m列的地图,每个格子都有对应的价值,有a,b两个人,都从左上角到右下角,且都只能向右向下走,a先出发,a每到一个格子,就会获得这个地方的价值,然后 ...
- Educational Codeforces Round 112 (Rated for Div. 2)
Educational Codeforces Round 112 (Rated for Div. 2) 题号 题目 知识点 A PizzaForces B Two Tables C Coin Rows ...
最新文章
- java自学 day1
- SAP 不支持交货单中同一个物料多个行项目HU与序列号组合发货场景
- android-Activity的执行流程
- 知乎高赞回答:裁员、降薪、996...这项能力让你寒冬蓄能
- 玩! 框架+ Google Guice
- Swift实现UIKit Dynamic动画
- 测试面试题集-MySQL数据库灵魂拷问加强版
- SQLite快速入门
- 质控工具之TrimGalore使用方法
- HP 瘦客户机 - 使用 ie4uinit.exe 应用时,Citrix HDX Flash 出现故障和错误
- CI(CodeIgniter)框架结构介绍
- Win10如何查看打印机端口号?
- 【ps-course】layer 图层
- linux下raid0创建教程,在 Linux 下使用 RAID(二):使用 mdadm 工具创建软件 RAID 0 (条带化)...
- 5-22近期工作总结、下一步工作安排及技术知识
- [教程] 如何复活一个完全死机的联发科设备
- 将iPad,iPhone或eReader的PDF电子书转换为ePub格式
- tinymce php,php - 用TinyMCE制作的PHP样式表(Hor Zebra) - SO中文参考 - www.soinside.com
- 微信开放平台开发第三方授权登陆(二):PC网页端
- mysql 百亿级_ES实现百亿级数据实时分析实战案例
热门文章
- go generate介绍及使用
- Spring Boot+Maven将配置文件打包到Jar包外方便运维修改配置
- spring mvc 传中文 到controller层乱码的 解决方法
- jsp java乱码转换_JSP中文乱码问题《转》
- 解决EF使用context.Database.SqlQuery时NotMapped属性列为空null的问题(转载)
- python的学习笔记/002-5(2018-5-21)
- Python操作MySQL存储,这些你都会了吗?
- jQuery跨域,添加自定义头部header
- 不定长数组取值交叉遍历组合生成算法
- redis超时原因排查