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 ...
随机推荐
- Linux环境编程之同步(二):条件变量
相互排斥锁用于上锁,条件变量则用于等待.条件变量是类型为pthread_cond_t的变量.一般使用例如以下函数: #include <pthread.h> int pthread_con ...
- BZOJ 1109 POI2007 堆积木Klo LIS
题目大意:给定一个序列,能够多次将某个位置的数删掉并将后面全部数向左串一位,要求操作后a[i]=i的数最多 首先我们如果最后a[i]=i的数的序列为S 那么S满足随着i递增,a[i]递增(相对位置不变 ...
- SignalR技术
Asp.net SignalR快速入门 一.前言 之前半年时间感觉自己有点浮躁,导致停顿了半年多的时间没有更新博客,今天重新开始记录博文,希望自己可以找回初心,继续沉淀.由于最近做的项目中用到Sign ...
- Java EE (8) -- Java EE Patterns
Java EE 模式目录由以下三个层组成: – 整合层(4) – 业务层(9) – 表示层(8) 涉及 Java EE 平台代码与其它类型应用程序或遗留系统的集成: 服务激活器 ...
- Windows Phone开发(24):启动器与选择器之发送短信
原文:Windows Phone开发(24):启动器与选择器之发送短信 本节我们通过一个简单的发送短信示例来演示一下如果配合使用PhoneNumberChooserTask和SmsComposeTas ...
- UVA - 12232 Exclusive-OR (并查集扩展偏离向量)
Description You are not given n non-negative integersX0,X1,..., Xn-1 less than220, but they do exist ...
- 比較Swift与HDFS话Ceph本质(by quqi99)
作者:张华 发表于:2014-06-21版权声明:能够随意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 (http://blog.csdn.net/quqi99 ) 作者将又 ...
- hdu4771 Stealing Harry Potter's Precious
注意--你可能会爆内存-- 假设一个直接爆搜索词-- 队列存储器元件被减少到-- #include<iostream> #include<map> #include<st ...
- document.getElementById()使用方法
document.getElementById使用 语法:oElement = document .getElementById ( sID ) 參数:sID――必选项. 字符串 (String) . ...
- vim代码折叠命令简短
作者:zhanhailiang 日期:2014-10-18 1. 通过fdm实现代码折叠:set fdm=xxx 有下面6种方式实现折叠: |fold-manual| manual Folds are ...