血崩- -

  1. /*
  2. CodeForces 839B - Game of the Rows [ 贪心,分类讨论] | Codeforces Round #428 (Div. 2)
  3. 注意
  4. 2 7
  5. 2 2 2 2 2 2 2
  6. 这组- -
  7. */
  8. #include <bits/stdc++.h>
  9. using namespace std;
  10. int n, n2, n4, a[105], k;
  11. bool solve()
  12. {
  13. n2 = 2*k;
  14. n4 = k;
  15. for (int i = 1; i <= n; i++)
  16. {
  17. if (a[i] >= 4 && n4)
  18. {
  19. int t = a[i]/4;
  20. a[i] -= min(t, n4)*4;
  21. n4 -= min(t, n4);
  22. }
  23. }
  24. for (int i = 1; i <= n; i++)
  25. {
  26. if (a[i] >= 2 && n2)
  27. {
  28. int t = a[i]/2;
  29. a[i] -= min(t, n2)*2;
  30. n2 -= min(t, n2);
  31. }
  32. }
  33. for (int i = 1; i <= n; i++)
  34. {
  35. if (a[i] && n2)
  36. {
  37. int t = a[i];
  38. a[i] -= min(t, n2);
  39. n2 -= min(t, n2);
  40. }
  41. }
  42. int m2 = 0, m1 = 0, m3 = 0;
  43. for (int i = 1; i <= n; i++)
  44. if (a[i] == 3) m3++;
  45. else if (a[i] == 2) m2++;
  46. else if (a[i] == 1) m1++;
  47. int sum = m3;
  48. if (m1 <= m2)
  49. {
  50. sum += m1;
  51. m2 -= m1;
  52. sum += m2/3*2;
  53. m2 %= 3;
  54. sum += m2;
  55. }
  56. else
  57. {
  58. sum += m2;
  59. m1 -= m2;
  60. sum += (m1+1)/2;
  61. }
  62. if (sum > n4) return 0;
  63. return 1;
  64. }
  65. int main()
  66. {
  67. scanf("%d%d", &k, &n);
  68. for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  69. if (solve()) puts("YES");
  70. else puts("NO");
  71. }

  

CodeForces 839B - Game of the Rows | Codeforces Round #428 (Div. 2)的更多相关文章

  1. CodeForces 839C - Journey | Codeforces Round #428 (Div. 2)

    起初误以为到每个叶子的概率一样于是.... /* CodeForces 839C - Journey [ DFS,期望 ] | Codeforces Round #428 (Div. 2) */ #i ...

  2. CodeForces 839D - Winter is here | Codeforces Round #428 (Div. 2)

    赛后听 Forever97 讲的思路,强的一匹- - /* CodeForces 839D - Winter is here [ 数论,容斥 ] | Codeforces Round #428 (Di ...

  3. Codeforces 839B - Game of the Rows

    839B - Game of the Rows 思路:先放4个的,然后再放2个的,最后再放1个的. 代码: #include<bits/stdc++.h> using namespace ...

  4. Codeforces 839B Game of the Rows - 贪心

    Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldie ...

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

  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. Codeforces Round #428 (Div. 2) 题解

    题目链接:http://codeforces.com/contest/839 A. Arya and Bran 题意:每天给你一点糖果,如果大于8个,就只能给8个,剩下的可以存起来,小于8个就可以全部 ...

  8. Codeforces Round #428 (Div. 2) D. Winter is here 容斥

    D. Winter is here 题目连接: http://codeforces.com/contest/839/problem/D Description Winter is here at th ...

  9. Codeforces Round #428 (Div. 2)E. Mother of Dragons

    http://codeforces.com/contest/839/problem/E 最大团裸题= =,用Bron–Kerbosch算法,复杂度大多博客上没有,维基上查了查大约是O(3n/3) 最大 ...

随机推荐

  1. 【转】iis7下站点日志默认位置

    本文转自:http://www.cnblogs.com/mincyw/p/3425468.html 在iis6时,通过iis管理器的日志配置可以找到站点日志存储的位置. 但是在iis7下,iis管理器 ...

  2. Django(一)安装启动

    Django下载/启动 1.下载安装 pip install django 或者 压缩文件下载地址:https://github.com/django/django/releases python s ...

  3. varnish CLI管理

    命令:varnishadm [-t timeout] [-S secret_file] [-T address:port] [-n name] [command [...]] ./varnishadm ...

  4. android 一个SQLite数据库多个数据表的基本使用框架 (带demo)

    android 一个SQLite数据库多个数据表(带demo) 前言        demo演示        一.搭建        二.建立实体类        三.建立数据库操作类        ...

  5. bzoj2152 聪聪可可 (树形dp)

    大意: 给定树, 随机选两点, 求两点距离是3的倍数的概率. 树形dp入门水题, 枚举每个点作为lca时的答案即可. #include <iostream> #include <qu ...

  6. pat L2_004

    一棵二叉搜索树可被递归地定义为具有下列性质的二叉树:对于任一结点, 其左子树中所有结点的键值小于该结点的键值: 其右子树中所有结点的键值大于等于该结点的键值: 其左右子树都是二叉搜索树. 所谓二叉搜索 ...

  7. TCP协议探究(二):超时与重试

    1 概述 TCP提供可靠的运输层. 可靠性保证之一:确认从另一端收到的数据. 但数据和确认都有可能会丢失.TCP通过在发送时设置一个定时器来解决这种问题. 如果当定时器溢出时还没有收到确认,它就重传该 ...

  8. 初学java3 条件判断

    三目运算符 条件? 正确结果:错误结果 if判断 单一条件判断 if(条件){ }else{ } 多种条件判断 if(){ }else if(){ } ... else{ } switch判断 swi ...

  9. 集合源码阅读——ArrayList

    ArrayList 关键点: >>扩容每次扩容1.5倍 >>modcount的作用 >>ArrayList的父类AbstractList的成员变量 >> ...

  10. oracle wm_concat函数用法

    在Oracle中使用wm_concat(column)可以实现字段的分组合并,逗号分隔.