链接

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的更多相关文章

  1. 【codeforces 789A】Anastasia and pebbles

    [题目链接]:http://codeforces.com/contest/789/problem/A [题意] 有n种物品,每种物品有wi个; 你有两个口袋,每个口袋最多装k个物品; 且口袋里面只能装 ...

  2. Codeforces 789A Anastasia and pebbles(数学,思维题)

    A. Anastasia and pebbles time limit per test:1 second memory limit per test:256 megabytes input:stan ...

  3. CF789A. Anastasia and pebbles

    /* CF789A. Anastasia and pebbles http://codeforces.com/contest/789/problem/A 水题 题意:有两个背包,每次分别可取k个物品, ...

  4. 789A Anastasia and pebbles

    A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input stan ...

  5. 【贪心】Codeforces Round #407 (Div. 2) A. Anastasia and pebbles

    贪心地一个一个尽可能往口袋里放,容易发现和顺序无关. #include<cstdio> #include<iostream> using namespace std; type ...

  6. Codeforces 789A Anastasia and pebbles( 水 )

    链接:传送门 题意:这个人每次都去公园捡石子,她有两个口袋,每个口袋最多装 k 个石子,公园有 n 种石子,每种石子 w[i] 个,询问最少几天能将石子全部捡完 思路:排个序,尽量每天都多装,如果 k ...

  7. codeforces 789 C. Functions again(dp求区间和最大)

    题目链接:http://codeforces.com/contest/789/problem/C 题意:就是给出一个公式 然后给出一串数求一个区间使得f(l,r)最大. 这题需要一个小小的处理 可以设 ...

  8. codeforces 509 B题 Painting Pebbles

    转载地址:http://blog.csdn.net/nike0good/article/details/43449739 B. Painting Pebbles time limit per test ...

  9. codeforces 789 B. Masha and geometric

    链接 B. Masha and geometric depression 题意 给你一个等比数列的首项和公比q,然后给出一个上限l,m个数字,在这个等比数列里,小于l且没有在m个数字里面出现过的可以写 ...

随机推荐

  1. 爬虫系列(八) 用requests实现天气查询

    这篇文章我们将使用 requests 调用天气查询接口,实现一个天气查询的小模块,下面先贴上最终的效果图 1.接口分析 虽然现在网络上有很多免费的天气查询接口,但是有很多网站都是需要注册登陆的,过程比 ...

  2. centos 7.2 安装php56-xml

    linux下, 使用thinkphp的模板标签,如 eq, gt, volist defined, present , empty等 标签时, 报错: used undefined function ...

  3. NOIP2017总结与反思

    手动博客搬家: 本文发表于20180213 00:01:05, 原地址https://blog.csdn.net/suncongbo/article/details/79319556 //由于12月生 ...

  4. 如鹏网JAVA培训笔记1(晓伟整理)

    JDK(Java Developmet Kit) JRE(Java RunTime Environment)的区别: JRE只有运行JAVA程序的环境,没有开发相关的工具;JDK=JRE+开发相关的工 ...

  5. Syncfusion在WinPhone8.1实现统计图

    using Syncfusion.UI.Xaml.Charts; public static SfChart InitCompareChart(string fundName, double tenT ...

  6. 大数据学习[16]--使用scroll实现Elasticsearch数据遍历和深度分页[转]

    题目:使用scroll实现Elasticsearch数据遍历和深度分页 作者:星爷 出处: http://lxWei.github.io/posts/%E4%BD%BF%E7%94%A8scroll% ...

  7. redis-windows上的安装与其他命令

    为什么用Redis 数据库的IO是一个性能瓶颈,需要用redis来解决,100个IO并发已经很不错了,因为数据库天生就需要写磁盘,而redis不需要实时写磁盘而又可以存入数据库 安装 以服务的方式启动 ...

  8. owin--Authentication

    下面的这个从httpcontext取出来的GetOwinContext的Authentication认证有很多关于cookie和session的方法,好像不实用owin也能取出来 private IA ...

  9. RubyMine生成reader/writer方法

    RubyMine生成reader/writer方法 在非类的ruby文件中,Alt+Insert会出现新建文件的选项: 在ruby文件的类中,Alt+Insert会出现get/set方法生成提示和重构 ...

  10. cefsharp 获取高度

    G.browser.GetBrowser().MainFrame.ExecuteJavaScriptAsync("$(document).height()"); // Get Do ...