**链接:****传送门 **

题意:这个人每次都去公园捡石子,她有两个口袋,每个口袋最多装 k 个石子,公园有 n 种石子,每种石子 w[i] 个,询问最少几天能将石子全部捡完

思路:排个序,尽量每天都多装,如果 k > w[i] ,那就直接将石子全部放入口袋,如果 k < w[i] 那就多次来装。


/*************************************************************************
> File Name: Codeforces789A.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年05月25日 星期四 10时43分22秒
************************************************************************/ #include<bits/stdc++.h>
using namespace std; const int MAX_N = 1e5 + 10;
int w[MAX_N] , n , k; bool cmp(int a,int b){
return a>b;
}
int main(){
while(~scanf("%d%d",&n,&k)){
for(int i = 0 ; i < n ; i++) scanf("%d",&w[i]);
sort( w , w + n , cmp );
int ans = 0;
for(int i = 0 ; i < n ; i++){
if( w[i] % k == 0 ) ans += w[i]/k;
else ans += w[i]/k + 1;
}
if( !(ans&1) ) ans /= 2;
else ans = ans/2 + 1;
printf("%d\n",ans);
}
return 0;
}

Codeforces 789A Anastasia and pebbles( 水 )的更多相关文章

  1. Codeforces 789A Anastasia and pebbles(数学,思维题)

    A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:stan ...

  2. 789A Anastasia and pebbles

    A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input stan ...

  3. codeforces 789 A. Anastasia and pebbles

    链接 A. Anastasia and pebbles 题意 这个人有两个口袋,有n种类型的鹅卵石,每种鹅卵石有wi个,每次可以放同一种最多k个,每次不能把不同类型的鹅卵石放进同一个口袋,但是她可以同 ...

  4. CF789A. Anastasia and pebbles

    /* CF789A. Anastasia and pebbles http://codeforces.com/contest/789/problem/A 水题 题意:有两个背包,每次分别可取k个物品, ...

  5. 【codeforces 789A】Anastasia and pebbles

    [题目链接]:http://codeforces.com/contest/789/problem/A [题意] 有n种物品,每种物品有wi个; 你有两个口袋,每个口袋最多装k个物品; 且口袋里面只能装 ...

  6. 【贪心】Codeforces Round #407 (Div. 2) A. Anastasia and pebbles

    贪心地一个一个尽可能往口袋里放,容易发现和顺序无关. #include<cstdio> #include<iostream> using namespace std; type ...

  7. Codeforces gym 100685 C. Cinderella 水题

    C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...

  8. CodeForces 459A Pashmak and Garden(水~几何-给两点求两点组成正方形)

    题目链接:http://codeforces.com/problemset/problem/459/A 题目大意: 给出两个点(在坐标轴中),求另外两个点从而构成一个正方形,该正方形与坐标轴平行. 如 ...

  9. CodeForces 710A King Moves(水题-越界问题)

    题目链接:http://codeforces.com/problemset/problem/710/A 题目大意:在一个棋盘中给出一个位置,判断该位置周围8个点还有几个点可以摆放棋子. AC代码解释解 ...

随机推荐

  1. 0918如何利用jmeter通过程序插入测试数据

    第一步 添加线程组 第二步 添加HTTP信息头管理器 第三步 添加HTTP请求 第四步 添加HTTP请求[POST] 第五步 添加查看结果树

  2. nodejs-n-nvm版本管理工具

    第一种版本管理工具: n n是Node的一个模块,作者是TJ Holowaychuk(鼎鼎大名的Express框架作者),就像它的名字一样,它的理念就是简单: "no subshells, ...

  3. Swift3.0 split函数切割字符串

    我们先看函数的原型: public func split(separator: Self.Iterator.Element, maxSplits: Int = default, omittingEmp ...

  4. Java:笔记-1

    ylbtech-Java:笔记-1 1.返回顶部 1. /** * 简介请求 * @return */ @RequestMapping("/JJ") public String j ...

  5. shp系列(二)——利用C++进行shp文件的读(打开)

    1.各数据类型及其字节数 BYTE 1;       char 1;    short 2;      int 4;    double 8; 2.位序big和little及其转换 对于位序是big的 ...

  6. Spring《七》ApplicationContext

    1.国际化支持 getMessage()提供了国际化支持. Bean中必须定义为messageSource. <bean id="messageSource" class=& ...

  7. 解决生成主键 id重复的解决办法

    作者:董春秋链接:https://www.zhihu.com/question/30674667/answer/49082988来源:知乎著作权归作者所有,转载请联系作者获得授权. 全局id生成器.我 ...

  8. Vue-router记录

    一.嵌套路由默认选中第一个子路由 可以给主路由加一个重定向的属性,把路径指向相应的子路由. { path: '/home', name: 'Home', //重定向 redirect: '/home/ ...

  9. Codeforces Round #445

    ACM ICPC 每个队伍必须是3个人 #include<stdio.h> #include<string.h> #include<stdlib.h> #inclu ...

  10. html5和css3的笔记

    h5+c3 W3C盒子模型和ie盒子模型 文档<!DOCTYPE html>加上的话,所有浏览器都按照W3C的盒子模型,否则ie会按照ie的盒子模型,它的content包括了padding ...