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的更多相关文章

  1. 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 ...

  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 ...

  3. 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 ...

  4. Co-prime Array&&Seating On Bus(两道水题)

     Co-prime Array Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Su ...

  5. 【思维+贪心】codeforces Game of the Rows

    http://codeforces.com/contest/839/problem/B [题意] 给定n组人,告诉每组人的人数,这些人要在飞机上坐座位 飞机上座位的分布看图可以知道,12  3456 ...

  6. 【Codeforces Round #428 (Div. 2) B】Game of the Rows

    [Link]:http://codeforces.com/contest/839/problem/B [Description] 给你n排的如题目所示的位置; 同一排中(1,2) 算相邻; (3,4) ...

  7. Gym100947E || codeforces 559c 组合数取模

    E - Qwerty78 Trip Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u S ...

  8. Codeforces 586D. Phillip and Trains 搜索

    D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: stan ...

  9. codeforces Diagrams & Tableaux1 (状压DP)

    http://codeforces.com/gym/100405 D题 题在pdf里 codeforces.com/gym/100405/attachments/download/2331/20132 ...

随机推荐

  1. js之数组排序

    数组,大家都不陌生,只要是学编程的人都知道这个入门的数据结构,在js中也是有数组这个概念的,跟普通的数组一样只是定义的形式不同罢了.下面是一个数组的排序代码: <html> <hea ...

  2. JaveScript-简介

    1.JaveScript:脚本语言.(弱类型语言)可以写在head,也可以写在head里,同样可以写在html外面<script src=""></script& ...

  3. POJ 分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  4. windows系统bat方式启动tomcat出现java.lang.OutOfmemoryError:PermGen Space 错误

    1.问题情景: 在部署项目时,将两个应用部署到同一个tomcat下,通过startup.bat启动服务时,控制台出现出现java.lang.OutOfmemoryError:PermGen Space ...

  5. python认识快速入门(一)

    接下来的一个多月开始学习python,在记录这些随笔的同时,如果你们能看到,希望能帮助到你们,如果有错误也请你们给指教! 主要记录的是对python的一个整体认识. 1.print 语句及“Hello ...

  6. Linux基础命令---head

    head 显示文件开头的几行,默认显示10行,可以使用选项-n来指定行数.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法   ...

  7. HTTP从入门到入土(5)——HTTP报文格式

    HTTP报文格式 HTTP报文分为请求报文和响应报文,只有发送了请求报文,才会有响应报文. 常见的报文格式如下所示:

  8. 05: api认证

    1.1 api认证原理介绍 1.api认证原理:客户端生成秘钥 1) 客户端与服务器端有一个相同的字符串作为auth_key 2) 客户端使用encryption="auth_key|tim ...

  9. 20145105 《Java程序设计》第7周学习总结

    20145105 <Java程序设计>第7周学习总结 教材学习内容总结 第十三章 时间与日期 一.认识时间与日期 (一)时间的度量 格林威治标准时间 世界时 国际原子时 世界协调时 Uni ...

  10. 20145212罗天晨 注入shellcode实验及Retuen-to-libc实验

    注入shellcode实验 实验步骤 一.准备一段shellcode 二.设置环境 Bof攻击防御技术 1.从防止注入的角度来看:在编译时,编译器在每次函数调用前后都加入一定的代码,用来设置和检测堆栈 ...