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\n",ans);
36     return 0;
37 }

 

posted @ 2017-03-30 12:01  BBBob  阅读(839)  评论(0编辑  收藏  举报