codeforces 789 A. Anastasia and pebbles
链接
题意
这个人有两个口袋,有n种类型的鹅卵石,每种鹅卵石有wi个,每次可以放同一种最多k个,每次不能把不同类型的鹅卵石放进同一个口袋,但是她可以同时把不同种类的鹅卵石放在不同的口袋里,一天只能收集一次,问收集完所有的鹅卵石需要多少天
做法
我们只需要计算出每种类型需要多少次装进袋子里,即 ,然后由于有两个袋子,所以
,考虑到不能整除的情况,所以要对结果向上取整,复杂度O(n)。
代码
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100010;
int main() {
int n,k;
cin>>n>>k;
int w[maxn];
int sum=0;
for(int i=0;i<n;i++){
cin>>w[i];
sum+=w[i]/k+(w[i]%k>0);
}
cout<<(sum/2+(sum%2>0))<<endl;
return 0;
}
codeforces 789 A. Anastasia and pebbles的更多相关文章
- 【codeforces 789A】Anastasia and pebbles
[题目链接]:http://codeforces.com/contest/789/problem/A [题意] 有n种物品,每种物品有wi个; 你有两个口袋,每个口袋最多装k个物品; 且口袋里面只能装 ...
- Codeforces 789A Anastasia and pebbles(数学,思维题)
A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:stan ...
- CF789A. Anastasia and pebbles
/* CF789A. Anastasia and pebbles http://codeforces.com/contest/789/problem/A 水题 题意:有两个背包,每次分别可取k个物品, ...
- 789A Anastasia and pebbles
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input stan ...
- 【贪心】Codeforces Round #407 (Div. 2) A. Anastasia and pebbles
贪心地一个一个尽可能往口袋里放,容易发现和顺序无关. #include<cstdio> #include<iostream> using namespace std; type ...
- Codeforces 789A Anastasia and pebbles( 水 )
链接:传送门 题意:这个人每次都去公园捡石子,她有两个口袋,每个口袋最多装 k 个石子,公园有 n 种石子,每种石子 w[i] 个,询问最少几天能将石子全部捡完 思路:排个序,尽量每天都多装,如果 k ...
- codeforces 789 C. Functions again(dp求区间和最大)
题目链接:http://codeforces.com/contest/789/problem/C 题意:就是给出一个公式 然后给出一串数求一个区间使得f(l,r)最大. 这题需要一个小小的处理 可以设 ...
- codeforces 509 B题 Painting Pebbles
转载地址:http://blog.csdn.net/nike0good/article/details/43449739 B. Painting Pebbles time limit per test ...
- codeforces 789 B. Masha and geometric
链接 B. Masha and geometric depression 题意 给你一个等比数列的首项和公比q,然后给出一个上限l,m个数字,在这个等比数列里,小于l且没有在m个数字里面出现过的可以写 ...
随机推荐
- Bootstrap内联表单
有时候我们需要将表单的控件都在一行内显示,就需要将表单控件设置成内联块元素(display:inline-block). 在Bootstrap框架中实现这样的表单效果是轻而易举的,你只需要在<f ...
- 0614MySQL的InnoDB索引原理详解
转自http://www.cnblogs.com/shijingxiang/articles/4743324.html MySQL的InnoDB索引原理详解 http://www.admin10000 ...
- [Javascript Crocks] Create a Maybe with a `safe` Utility Function
In this lesson, we’ll create a safe function that gives us a flexible way to create Maybes based on ...
- iOS开发-自己定义重用机制给ScrollerView加入子视图
事实上这个问题我非常早就想过,仅仅是没有通过去写程序实现,昨天有人提起,我就巧了一下 不知道大家打印郭tableview:cellforrow中cell初始的次数,也就是重用池中的cell个数.这个是 ...
- 分享一个iOS输入框特殊限制的代码 UITextField (Validation)
//个人总结.欢迎新增或改动 #import <UIKit/UIKit.h> typedef enum{ VALIDATION_TYPE_NUM_VALIDATED = 0,//数字 VA ...
- tslib-触摸屏校准
5.1移植tslib 5.1.1在https://github.com/kergoth/tslib下载最新的tslib 5.1.2为虚拟机里的Linux系统安装工具 sudo apt-get ins ...
- 轻快的VIM(五):复制
操作相同文本的时候复制尤其有效,在Windows中我们都习惯了先用鼠标选择文本 而Vim下则不用那么麻烦,你甚至可以使用可视模式操作,但这里先略过 我在这一节主要说说命令模式下的复制 在讲复制之前我要 ...
- bzoj5194: [Usaco2018 Feb]Snow Boots
还真是.. 就是 一个被不点名批评的垃圾骗分暴力选手被普及难度的省选信心(??)模拟赛艹爆的题解 的t3嘛... #include<cstdio> #include<iostream ...
- 产生冠军--hdoj
产生冠军 Time Limit : 1000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submissi ...
- [CF1139 E] Maximize Mex 解题报告 (二分图匹配)
interlinkage: https://codeforces.com/contest/1139/problem/E description: 有$n$个学生,$m$个社团,每个学生有一个能力值,属 ...