zoukankan      html  css  js  c++  java
  • CF789A. Anastasia and pebbles

     1 /*
     2  CF789A. Anastasia and pebbles
     3  http://codeforces.com/contest/789/problem/A
     4  水题
     5  题意:有两个背包,每次分别可取k个物品,要求每次背包中的物品都是一种
     6  问要取多少次。
     7  对于每种物品,都要取ceil(n/k)次,因此只要加起来再除以2就是答案
     8  */
     9 #include <cstdio>
    10 #include <algorithm>
    11 #include <cstring>
    12 #include <cmath>
    13 #include <vector>
    14 #include <queue>
    15 //#define test
    16 using namespace std;
    17 const int Nmax=1e6+5;
    18 int num[Nmax];
    19 int main()
    20 {
    21     #ifdef test
    22     #endif
    23     int n,k;
    24     scanf("%d%d",&n,&k);
    25     for(int i=1;i<=n;i++)
    26     {
    27         scanf("%d",&num[i]);
    28     }
    29     int ans=0;
    30     for(int i=1;i<=n;i++)
    31     {
    32         ans+=(int)ceil((double)num[i]/k);
    33     }
    34     ans=(int)ceil((double)ans/2);
    35     printf("%d
    ",ans);
    36     return 0;
    37 }
  • 相关阅读:
    记坑
    常用模板
    ACM-东北赛划水记
    jzoj 4178游戏
    JZOI 4163
    jzoj 4146踩气球
    jzoj 5589. 缩点
    jzoj 5588 %%%
    jzoj 5571 ffs
    BJOI 2017 Kakuro
  • 原文地址:https://www.cnblogs.com/BBBob/p/6645432.html
Copyright © 2011-2022 走看看