Codeforces 789A Anastasia and pebbles( 水 )
**链接:****传送门 **
题意:这个人每次都去公园捡石子,她有两个口袋,每个口袋最多装 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( 水 )的更多相关文章
- Codeforces 789A Anastasia and pebbles(数学,思维题)
A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- 789A Anastasia and pebbles
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input stan ...
- codeforces 789 A. Anastasia and pebbles
链接 A. Anastasia and pebbles 题意 这个人有两个口袋,有n种类型的鹅卵石,每种鹅卵石有wi个,每次可以放同一种最多k个,每次不能把不同类型的鹅卵石放进同一个口袋,但是她可以同 ...
- CF789A. Anastasia and pebbles
/* CF789A. Anastasia and pebbles http://codeforces.com/contest/789/problem/A 水题 题意:有两个背包,每次分别可取k个物品, ...
- 【codeforces 789A】Anastasia and pebbles
[题目链接]:http://codeforces.com/contest/789/problem/A [题意] 有n种物品,每种物品有wi个; 你有两个口袋,每个口袋最多装k个物品; 且口袋里面只能装 ...
- 【贪心】Codeforces Round #407 (Div. 2) A. Anastasia and pebbles
贪心地一个一个尽可能往口袋里放,容易发现和顺序无关. #include<cstdio> #include<iostream> using namespace std; type ...
- Codeforces gym 100685 C. Cinderella 水题
C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C ...
- CodeForces 459A Pashmak and Garden(水~几何-给两点求两点组成正方形)
题目链接:http://codeforces.com/problemset/problem/459/A 题目大意: 给出两个点(在坐标轴中),求另外两个点从而构成一个正方形,该正方形与坐标轴平行. 如 ...
- CodeForces 710A King Moves(水题-越界问题)
题目链接:http://codeforces.com/problemset/problem/710/A 题目大意:在一个棋盘中给出一个位置,判断该位置周围8个点还有几个点可以摆放棋子. AC代码解释解 ...
随机推荐
- 20150805-20150807 tradeDate-----python
1.创建数据库(strategy).表(trade_date 交易日) create database strategy default character set utf8 collate utf8 ...
- Spring MVC-表单(Form)处理示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_form_handling.htm 说明:示例基于Spring MVC 4.1.6 ...
- Maven错误:[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?的解决方法
错误: [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather tha ...
- 服务器session,Tomcat有自己的session维护机制,apache有自己的session维护机制
1.SESSION一般不是你说的这种工作方式,你打开一个浏览器,再打开一个,请求同一个网址,然后其中一个登陆,另外一个绝对不会也登陆.SESSION和浏览器本身这个程序就是挂钩的,一般不通过IP和端口 ...
- POJ 3335
/*半平面交求核心的增量法: 假设前N-1个半平面交,对于第N个半平面,只需用它来交前N-1个平面交出的多边形. 算法开始时,调整点的方向为顺时针方向,对于是否为顺时针,只需求出其面积,若为正,必为逆 ...
- angularjs时间轴
1.炫酷的图片是开端啊 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- 怎样 获取 ios的系统版本
获得Ios系统版本的函数,比方 函数定义: [cpp] view plaincopy + (float)getIOSVersion; 函数实现: [cpp] view plaincopy + (flo ...
- 【cl】本地安装maven的jar包报错Artifact is already in the local repository
原因是我直接把jar包放在了仓库里面 解决办法:将jar办放在不是仓库路径位置,在进行install就okle
- 在IIS6,7中部署ASP.NET网站
查看web.config文件 ASP.NET网站与一般的桌面程序不同,不是拷贝过来就能运行的(数据库连接除外). 要想运行它,通常需要一些配置过程.但是,我们到底需要配置什么呢?答案是:查看web.c ...
- Centos7操作系统部署指南
一.硬件环境: Dell R620 二.软件环境: Centos6.4 X86_64 +KVM Windows7+vnc 三.安装说明 操作系统更新之迅速,让作为新手的系统运维人员有点措手不及,相对于 ...