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个数字里面出现过的可以写 ...
随机推荐
- 32.es读请示内部分发原理
当客户端发送一次读请求时,大致会经过以下几个步骤 1.客户端发送一个请求过去,es的一个node接收到这个请求(随机的node),这个node就被es内部分配成coordinating node(协调 ...
- MySQL中index和key的关系
KEY is normally a synonym for INDEX. The key attribute PRIMARY KEY can also be specified as just KEY ...
- Tkinter之输入框操作
昨天看好的,更新一下记录而已. #coding: utf8 from Tkinter import * def reg(): s1 = e1.get() s2 = e2.get() t1 = len( ...
- 洛谷 P2534 [AHOI2012]铁盘整理
P2534 [AHOI2012]铁盘整理 题目描述 输入输出格式 输入格式: 共两行.第一行为铁盘个数N(1<=N<=50),第二行为N个不同的正整数,分别为从上到下的铁盘的半径R.(1& ...
- iostat -x 1 查看磁盘的IO负载
Linux系统出现了性能问题.一般我们能够通过top.iostat,vmstat等命令来查看初步定位问题.当中iostat能够给我们提供丰富的IO状态数据 $ iostat -x -1 avg-cp ...
- 火云开发课堂 - 《使用Cocos2d-x 开发3D游戏》系列 第一节:3D时代来临!
<使用Cocos2d-x 开发3D游戏>系列在线课程 第一节:3D时代来临.Cocos2d-x程序猿的机遇和挑战! 视频地址:http://edu.csdn.net/course/deta ...
- oc6--类方法
// // main.m // 第一个OC类-类方法 #import <Foundation/Foundation.h> // 1.编写类的声明 @interface Iphone : N ...
- php 日期格式化
date('Y-m-d H:i:s',time()); 2014-09-01 05:06:01 date(' y-n-j G:i:s',time()); 14-9-1 5:06:01 mktime(h ...
- AndroidStudio项目CMakeLists解析
# For more information about using CMake with Android Studio, read the# documentation: https://d.and ...
- Chrome 行情抓取插件
Chrome 行情抓取插件 上班想偷偷摸摸看行情?自己动手写插件啊,尝试写了一个,新建文件夹,命名为StockMonitor,放入文件如下: 3个.png图标文件,19X19.48X48.128X12 ...