Codeforces Round #252 (Div. 2) 441B. Valera and Fruits
英语不好就是坑啊。这道题把我坑残了啊。5次WA一次被HACK。第二题得分就比第一题高10分啊。
以后一定要加强英语的学习,要不然就跪了。
题意:有一个果园里有非常多树,上面有非常多果实,为了不然成熟的果实腐烂,必须在两天之内收集起来。给出果园有的树,以及该树上的果实个数,工人每天能够採集的上限,求出这段时间之后,能收集到的最大值。
想法非常easy。优先採集上一天剩下的果实(假设有剩下)。假设还能採集再採集今天成熟的果实。假设採集不玩就把当前天数的果实移动到下一天去优先採集。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int n,v;
int i;
int ans=0;
int cnt;
int c;
int a[5000],b,d;
memset(a,0,sizeof(a));
scanf("%d %d",&n,&v);
for(i=1;i<=n;i++)
{
scanf("%d %d",&b,&d);
a[b]+=d;
}
cnt=0;
for(i=0;i<=3001;i++)
{
c=v;
if(cnt<=c)
{
c-=cnt;
ans+=cnt;
}
else
{
ans+=c;
c=0;
}
if(c>=a[i])
{
ans+=a[i];
cnt=0;
}
else
{
cnt=a[i]-c;
ans+=c;
}
}
printf("%d\n",ans);
return 0;
}
Codeforces Round #252 (Div. 2) 441B. Valera and Fruits的更多相关文章
- Codeforces Round #252 (Div. 2) B. Valera and Fruits(模拟)
B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #252 (Div. 2) B. Valera and Fruits
#include <iostream> #include <vector> #include <algorithm> #include <map> us ...
- codeforces Round #252 (Div. 2) C - Valera and Tubes
贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完 由于数据比较小,可以先打表 #include <iostream> #include <vector> #i ...
- Codeforces Round #252 (Div. 2) A - Valera and Antique Items
水题 #include <iostream> #include <set> #include <vector> #include <algorithm> ...
- Codeforces Round 252 (Div. 2)
layout: post title: Codeforces Round 252 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- [Codeforces Round #237 (Div. 2)] A. Valera and X
A. Valera and X time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #216 (Div. 2) D. Valera and Fools
题目链接:http://codeforces.com/contest/369/problem/D 注意题意:所有fools都向编号最小的fool开枪:但每个fool都不会笨到想自己开枪,所以编号最小的 ...
- Codeforces Round #252 (Div. 2) D
http://codeforces.com/problemset/problem/441/D 置换群的基本问题,一个轮换内交换成正常顺序需要k-1次,k为轮换内元素个数 两个轮换之间交换元素,可以把两 ...
- Codeforces Round #216 (Div. 2) B. Valera and Contest
#include <iostream> #include <algorithm> #include <vector> using namespace std; in ...
随机推荐
- SE 2014年4月12日
BGP基础实验 拓扑 步骤: 1. 完成基本的配置 2. 按照需求自治系统AS 100 全网运行OSPF 单区域 3. 完成BGP基本配置 [RT2]bgp 100 [RT2-bgp]peer 67. ...
- Scala的XML操作
8. XML 8.1. 生成 Scala原生支持xml,就如同Java支持String一样,这就让生成xml和xhtml非常easy优雅: val name = "james ...
- 一位同学3年通过CPA, CFA, ACCA的经验
3 年从 ACCA!!! 今天收到 ACCA,只去考了一门,因为要下 field,可恶的 H R 和 manager 都不批准我的假.不过还好,功夫不负有心人,CPA 了,也是本科毕业那年. 本科结束 ...
- ok6410 u-boot-2012.04.01移植七完善u-boot移植(u-boot移植结束)
继ok6410 u-boot-2012.04.01移植六后,开发板已支持MLC NAND.DM9000等.但还需要完善比如环境变量.mtdpart分区.裁剪.制作补丁等.下面的工作就是完善移植的u-b ...
- ecshop 浏览历史样式的修改
ecshop的浏览历史的样式,例如我修改的是只让浏览历史显示浏览历史的商品名称 而不显示浏览历史的商品的价格和图片 首先找到要修改 的文件includes\lib_insert.php 找到函数fun ...
- 【spring源代码分析】--Bean的解析与注冊
接着上一节继续分析,DefaultBeanDefinitionDocumentReader的parseBeanDefinitions方法: protected void parseBeanDefini ...
- ZooKeeperEclipse 小工具
插件地址:ZooKeeperEclipse http://www.massedynamic.org/eclipse/updates/ 安装ZooKeeperEclipse插件过程例如以下: Step ...
- HTML 5最终确定,八年后,我们再谈谈如何改变世界
从原:http://www.36kr.com/p/216655.html 我们第一次谈论HTML5要改变世界大概是由于乔布斯,他坚持在iOS上不兼容Flash,在Adobe统治多媒体开发的那个年代.这 ...
- C++-传值与传引用的差别
//值传递与引用传递的差别 #include <iostream> #include <iomanip> using namespace std; void fiddle(in ...
- hdu1664 Different Digits
求出n的倍数m,要求m使用的不同数字最少,且最小. 一开始不知道怎么搜,因为不知道m由多少个不同的数字组成. 然后百度了一下,看到和数论有关. m可能使用的数字的个数可能为一个或者两个 a,aa,aa ...