Codeforces 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[]; int main()
{
int n,k;
cin>>n>>k;
int c2=n*;
int c4=n;
for(int i=;i<=k;i++)cin>>a[i]; for(int i=;i<=k;i++)
{
int c=min(c4,a[i]/);
c4-=c;
a[i]-=c*;
} c2+=c4;//剩下的4个连在一起的也可以放2个的
for(int i=;i<=k;i++)
{
int c=min(c2,a[i]/);
c2-=c;
a[i]-=c*;
} int t=c2+c4;//原来的4个连在一起的放二个的时候只放了一半,而且放了一半也可能没放满
for(int i=;i<=k;i++)
{
t-=a[i];
} if(t<)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
return ;
}
Codeforces 839B - Game of the Rows的更多相关文章
- CodeForces 839B - Game of the Rows | Codeforces Round #428 (Div. 2)
血崩- - /* CodeForces 839B - Game of the Rows [ 贪心,分类讨论] | Codeforces Round #428 (Div. 2) 注意 2 7 2 2 2 ...
- Codeforces 839B Game of the Rows - 贪心
Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldie ...
- Codeforces 839B Game of the Rows【贪心】
B. Game of the Rows time limit per test:1 second memory limit per test:256 megabytes input:standard ...
- Co-prime Array&&Seating On Bus(两道水题)
Co-prime Array Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Su ...
- 【思维+贪心】codeforces Game of the Rows
http://codeforces.com/contest/839/problem/B [题意] 给定n组人,告诉每组人的人数,这些人要在飞机上坐座位 飞机上座位的分布看图可以知道,12 3456 ...
- 【Codeforces Round #428 (Div. 2) B】Game of the Rows
[Link]:http://codeforces.com/contest/839/problem/B [Description] 给你n排的如题目所示的位置; 同一排中(1,2) 算相邻; (3,4) ...
- Gym100947E || codeforces 559c 组合数取模
E - Qwerty78 Trip Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u S ...
- Codeforces 586D. Phillip and Trains 搜索
D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: stan ...
- codeforces Diagrams & Tableaux1 (状压DP)
http://codeforces.com/gym/100405 D题 题在pdf里 codeforces.com/gym/100405/attachments/download/2331/20132 ...
随机推荐
- discuz财付通也阵亡了
今日做交易部分,然后焦头烂额. 首先这积分,威望,金钱,什么鬼,乱七八糟的...... 然后这支付宝,啊,,,,,竟然停止个人接口了,不得已要使用财付通. %&……*&……&不 ...
- 利用js添加class
来来来,开篇点题. 分页应用.当在当前页时,分页的数字有个框之类的. 重要代码如下 <ul class="pagination"> <li><a hr ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON MaxImage1
zw版[转发·台湾nvp系列Delphi例程]HALCON MaxImage1 procedure TForm1.FormShow(Sender: TObject);begin Set8087CW($ ...
- Lua安装
部署环境 lua-5.1.1 VM虚拟机redhat6.5-x64:192.168.1.201 Xshell4 安装 步骤一:安装依赖 yum install -y readline yum inst ...
- python 爬虫煎蛋网
import urllib.request import os from urllib import error import re import base64 def url_open(url): ...
- C++:struct和union 内存字节对齐问题
转自:http://blog.csdn.net/wangyanguiyiyang/article/details/53312049 struct内存对齐问题 1:数据成员对齐规则:结构(struct) ...
- 火狐使用Ctrl新开窗口不生效
使用window.open新开页面,火狐浏览器无法使用Ctrl新开窗口后页面停留在当前页面,兼容性问题,使用<a>或者<router-link>标签即可解决 --贡献者:毛毛
- c++性能之对象与指针性能比较、以及java与c++性能对比实测
为了更加直观的比较,好吧,我们选择以对象的初始化并add到list为例子. 首先,定义object如下: #include <string> #pragma once using name ...
- FTP-IIS Web
快速搭建一个本地的FTP服务器 如果需要开发FTP文件上传下载功能,那么需要在本机上搭建一个本地FTP服务器,方便调试. 第一步:配置IIS Web服务器 1.1 控制面板中找到“程序”并打开 1 ...
- jQuery 中 $( ) 函数的用法总结
摘要 jQuery对象: 具有jquery框架设置的所有功能的调用者, 就是该框架的对象 $又是什么?: $就是jQuery对象, jQuery对象为window的全局属性, 所以可以直接使用 如何自 ...