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个数字里面出现过的可以写 ...
随机推荐
- 爬虫系列(二) Chrome抓包分析
在这篇文章中,我们将尝试使用直观的网页分析工具(Chrome 开发者工具)对网页进行抓包分析,更加深入的了解网络爬虫的本质与内涵 1.测试环境 浏览器:Chrome 浏览器 浏览器版本:67.0.33 ...
- lunix下的redis数据库操作——hash(哈希)
哈希,形如:key : (field : value) 创建:(可以理解为users用户,name为xxx) hset users name xxx 查看: hget users name # &qu ...
- MySQL主要命令(4)
显示数据, 给列区别名: select coL_name as 别名 from table_name;
- 0823关于整理MySQL死锁
-- 更多的是需要理解 http://hedengcheng.com/?p=577 -- 何登成 关于WHERE的提取http://www.cnblogs.com/metoy/p/5545580.ht ...
- ZooKeeper搭建系列集 (这套很全,也很详细)
原文链接:http://blog.csdn.net/shatelang/article/details/7596007 本篇文章结构: 总共包括10个系列 ZooKeeper系列之一:ZooKeepe ...
- ul,li不能左右居中的问题
近期帮朋友做一个他们公司的商品站点,用到了曾经学到的html+css技术,当然做站点少不了Javascript和jquery这些..... 这个功能主要实现了导航条里面的条目是居中的.所以声明了ul, ...
- 5.2 calendar--通用日期的相关函数(4)
calendar类提供以下的函数来推断日历相关的内容: calendar.setfirstweekday(weekday) 设置一周里那一天作为第一天.0是表示星期一,6是表示星期天. 样例: #py ...
- HDU 1240
#include <iostream> #include <cstdio> using namespace std; ; char maze[MAX][MAX][MAX]; s ...
- 区间最小值 线段树 (2015年 JXNU_ACS 算法组暑假第一次周赛)
区间最小值 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other) Total Submiss ...
- 【POJ 2486】 Apple Tree(树型dp)
[POJ 2486] Apple Tree(树型dp) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8981 Acce ...