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代码解释解 ...
随机推荐
- Spring MVC-表单(Form)标签-复选框(Checkbox)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_checkbox.htm 说明:示例基于Spring MVC 4.1.6. 以下示 ...
- C#编程中,在页面上如何弹出确认删除对话框
对于页面完成一个操作后,弹出一个对话框提示是否“操作成功”.举例如下:Response.Write("<script>alert('删除成功!')</script>& ...
- [GraphQL] Apollo React Mutation Component
In this lesson I refactor a React component that utilizes a higher-order component for mutations to ...
- Java中Void占位符的測试及个人理解
Java对Void类的说明是:Void 类是一个不可实例化的占位符类,它保持一个对代表 Java keyword void 的 Class 对象的引用. 代表的是: 代表主要的 Java 类型 voi ...
- [JXOI 2018] 游戏 解题报告 (组合数+埃氏筛)
interlinkage: https://www.luogu.org/problemnew/show/P4562 description: solution: 注意到$l=1$的时候,$t(p)$就 ...
- Python笔记(十一)——数据抓取例子
上班时候想看股票行情怎么办?试试这个小例子,5分钟拉去一次股票价格,预警: #coding=utf-8 import re import urllib2 import time import thre ...
- POJ 1654 乱搞题?
题意: 从一个点出发,8个方向,给出每一步的方向,求出走过的路径形成的多边形的面积. 思路: 先普及一下向量叉乘.. (摘自度娘) 也就是x1y2-x2y1. 那这不就好说了嘛. 一个经过原点的闭合多 ...
- python学习-字符串 列表 元祖
目录 Python翻转字符串(reverse string) 简单的步长为-1, 即字符串的翻转(常用) 递归反转 借用列表,使用reverse()方法 字符串常用操作 index split 切片 ...
- [XJOI]noip40 T2统计方案
统计方案 小B写了一个程序,随机生成了n个正整数,分别是a[1]..a[n],他取出了其中一些数,并把它们乘起来之后模p,得到了余数c.但是没过多久,小B就忘记他选了哪些数,他想把所有可能的取数方案都 ...
- 5、Iterator迭代器的使用
package cn.itcast_02; import java.util.ArrayList; import java.util.Collection; import java.util.Iter ...