bzoj4096 [Usaco2013 dec]Milk Scheduling
Description
Input
Output
* Line 1: The maximum number of gallons of milk Farmer John can obtain.
Sample Input
10 3
7 5
8 1
2 1
INPUT DETAILS: There are 4 cows. The first produces 10 gallons of milk if milked by time 3, and so on.
Sample Output
OUTPUT DETAILS: Farmer John milks cow 3 first, giving up on cow 4 since she cannot be milked by her deadline due to the conflict with cow 3. Farmer John then milks cows 1 and 2.
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdlib>
using namespace std;
priority_queue<int> q;
int n,tm,num,ans;
struct dat{int c,w;}a[];
bool operator <(const dat &a,const dat &b){return a.c>b.c;}
int main()
{
q.empty();
scanf("%d",&n);
for (int i=;i<=n;i++)scanf("%d%d",&a[i].w,&a[i].c);
sort(a+,a+n+);
tm=a[].c;q.push(a[].w);num=;
a[n+].w=;a[n+].c=;
for (int i=;i<=n+;i++)
{
int go=min(tm-a[i].c,num);
while (go!=)ans+=q.top(),q.pop(),num--,go--;
q.push(a[i].w);num++;tm=a[i].c;
}
printf("%d\n",ans);
}
bzoj4096
bzoj4096 [Usaco2013 dec]Milk Scheduling的更多相关文章
- BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 [后缀数组]
1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1017 Solved: ...
- bzoj1717: [Usaco2006 Dec]Milk Patterns 产奶的模式
后缀数组+二分答案+离散化.(上次写的时候看数据小没离散化然后一直WA...写了lsj师兄的写法. #include<cstdio> #include<cstring> #in ...
- [Usaco2006 Dec]Milk Patterns
[Usaco2006 Dec]Milk Patterns Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他不能预见明天 产奶的质量,但连续的若干天的 ...
- BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式( 二分答案 + 后缀数组 )
二分答案m, 后缀数组求出height数组后分组来判断. ------------------------------------------------------------ #include&l ...
- BZOJ#1717:[Usaco2006 Dec]Milk Patterns 产奶的模式(后缀数组+单调队列)
1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他不能预见明天产奶的 ...
- BZOJ_1717_[Usaco2006 Dec]Milk Patterns 产奶的模式_后缀数组
BZOJ_1717_[Usaco2006 Dec]Milk Patterns 产奶的模式_后缀数组 Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他 ...
- 【BZOJ4094】[Usaco2013 Dec]Optimal Milking 线段树
[BZOJ4094][Usaco2013 Dec]Optimal Milking Description Farmer John最近购买了N(1 <= N <= 40000)台挤奶机,编号 ...
- 【BZOJ1717】[Usaco2006 Dec]Milk Patterns 产奶的模式 后缀数组
[BZOJ1717][Usaco2006 Dec]Milk Patterns Description 农夫John发现他的奶牛产奶的质量一直在变动.经过细致的调查,他发现:虽然他不能预见明天产奶的质量 ...
- bzoj 4094: [Usaco2013 Dec]Optimal Milking
4094: [Usaco2013 Dec]Optimal Milking Description Farmer John最近购买了N(1 <= N <= 40000)台挤奶机,编号为1 . ...
随机推荐
- [置顶] flex4事件监听与自定义事件分发(三)
1.我们来说一下自定义事件子类.什么时候创建新的事件类以及怎么创建. (1)说一下,我们什么时候需要自定义事件类.举例说明,在flex中事件的基类是Event,而当我们点击某个按钮或者是单击某个组件的 ...
- swift学习资料初探
1. http://code.csdn.net/news/2820075
- [小技巧] 打造属于 Dell XPS 13 (9350) 的专属 Windows 7 iso 镜像
MacBook Air 13, Dell XPS 13 和 Thinkpad X1 Carbon 都是轻薄笔记本中设计优秀的典范,受到很多用户追捧. 不过对于 Windows 阵营的笔记本,最近有个坏 ...
- Android中使用ListView绘制自定义表格(2)
上回再写了<Android中使用ListView绘制自定义表格>后,很多人留言代码不全和没有数据样例.但因为项目原因,没法把源码全部贴上来.近两天,抽空简化了一下,做了一个例子. 效果图如 ...
- /dev/null 文件
/dev/null 文件 如果希望执行某个命令,但又不希望在屏幕上显示输出结果,那么可以将输出重定向到 /dev/null: $ command > /dev/null /dev/null 是一 ...
- 公共Webservice
网络上可供测试的Web Service腾讯QQ在线状态 WEB 服务Endpoint: http://www.webxml.com.cn/webservices/qqOnlineWebService. ...
- 自定义Toast
简易自定义Toast public class MainActivity extends ListActivity );//边角 gradientDrawable.setGradien ...
- java基础01
1. /** * JDK: (Java Development ToolKit) java开发工具包.JDK是整个java的核心! * 包括了java运行环境 JRE(Java Runtime Env ...
- 苹果手机button有色差
input[type=button], input[type=submit], input[type=file], button { cursor: pointer; -webkit-appearan ...
- elasticsearch中的概念简述
Near Realtime(NRT) Elasticsearch接近实时.从为一个文档建立索引到可被搜索,正常情况下有1秒延迟. Cluster 一个集群有一个唯一的名字,默认是"elast ...