[LUOGU] P2920 [USACO08NOV]时间管理Time Management
#include<iostream>
#include<algorithm>
#include<cstdio> using namespace std; const int MAXN=; inline int rd(){
int ret=,f=;char c;
while(c=getchar(),!isdigit(c))f=c=='-'?-:;
while(isdigit(c))ret=ret*+c-'',c=getchar();
return ret*f;
} struct Node{
int lon,tim;
}nodes[MAXN];
bool cmp(const Node &x,const Node &y){
return x.tim<y.tim;
} int n; int main(){
// freopen("manage.in","r",stdin);
// freopen("manage.out","w",stdout);
n=rd();
for(int i=;i<=n;i++){
nodes[i].lon = rd();
nodes[i].tim = rd();
}
sort(nodes+,nodes++n,cmp);
long long sum=,mn=(<<),v;
for(int i=;i<=n;i++){
sum+=nodes[i].lon;
v=nodes[i].tim-sum;
if(v<) return puts("-1"),;
mn=min(mn,v);
}
printf("%lld",mn);
return ;
}
[LUOGU] P2920 [USACO08NOV]时间管理Time Management的更多相关文章
- bzoj1620 / P2920 [USACO08NOV]时间管理Time Management
P2920 [USACO08NOV]时间管理Time Management 显然的贪心. 按deadline从大到小排序,然后依次填充时间. 最后时间为负的话那么就是无解 #include<io ...
- P2920 [USACO08NOV]时间管理Time Management
P2920 [USACO08NOV]时间管理Time Management 题目描述 Ever the maturing businessman, Farmer John realizes that ...
- 洛谷 P2920 [USACO08NOV]时间管理Time Management
传送门 题目大意: 每个工作有截至时间和耗费时间,n个工作求最小开始时间. 题解: 贪心 从n-1安排,让结束时间尽量的晚. 注意:优先级 cout<<st<0?-1:st; (X ...
- 题解 P2920 【[USACO08NOV]时间管理Time Management】
题面 作为一名忙碌的商人,约翰知道必须高效地安排他的时间.他有N工作要 做,比如给奶牛挤奶,清洗牛棚,修理栅栏之类的. 为了高效,列出了所有工作的清单.第i分工作需要T_i单位的时间来完成,而 且必须 ...
- [USACO08NOV]时间管理Time Management(排序,贪心)
题目描述 作为一名忙碌的商人,约翰知道必须高效地安排他的时间.他有N工作要 做,比如给奶牛挤奶,清洗牛棚,修理栅栏之类的. 为了高效,列出了所有工作的清单.第i分工作需要T_i单位的时间来完成,而 且 ...
- [USACO08NOV]时间管理Time Management
题目描述 Ever the maturing businessman, Farmer John realizes that he must manage his time effectively. H ...
- CMSIS-RTOS 时间管理之时间延迟Time Delay
时间管理 Time Management 此RTOS除了可以把你的应用代码作为线程运行,它还可以提供一些时间服务功能,使用这些功能你就可以访问RTOS的一些系统调用. 时间延迟Time Delay 在 ...
- BZOJ 1620: [Usaco2008 Nov]Time Management 时间管理( 二分答案 )
二分一下答案就好了... --------------------------------------------------------------------------------------- ...
- 1620: [Usaco2008 Nov]Time Management 时间管理
1620: [Usaco2008 Nov]Time Management 时间管理 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 506 Solved: ...
随机推荐
- iOS Button选中与取消
/** * 是否点击 */ @property (nonatomic ,assign) BOOL selected; /** * button 点击事件选中取消选中 */ - (void)handl ...
- Swift3.0 字符串(string)
string常用的一些操作方式 //字符串 //1.初始化字符串 //1.1通过字面量赋值的方式初始化字符串 let tempStrig = "this is temp string&quo ...
- hdoj5842【水题】
比赛的时候还特别撒比地写了二分的那个写法,然后wa了一发,因为这个集合的翻译成自然数集.还是转换了一下,还是去写了一个二分. 后面就是出现几种就是多长... 比赛的真的非常非常挫的code-. #in ...
- Unity Transform常识(转)
Variables position: Vector3 物体在世界坐标中的位置. transform.position=Vector3(10,10,10)//把物体放到(x=10,y=10,z= ...
- R Factor 如何转为c()
从 R语言本身来说 > f [1] 130015.IB 130013.IB Levels: 130013.IB 130015.IB > data = c(f) > data [1] ...
- 3.bool布尔值int,str的转化,字符串的常用方法,字符串format,is判断(字符串的数字),for循环
1.bool 布尔值 bool 布尔值 -- 用于条件使用 True 真 False 假 True 真 False 假 print(bool(-10)) # 0 是 False 非0的都是True p ...
- N Queen Again LightOJ - 1061
N Queen Again LightOJ - 1061 首先预处理(或打表)出所有八皇后的解法(只有92种).然后枚举目标状态,对于每一个目标状态用一个状压dp求出到达那个状态的最小费用.到达任何一 ...
- HBase文档操作--练习篇
1.查询学生的所有信息 数据准备 var persons = [{ name:"jim", age:25, email:"75431457@qq.com", c ...
- Sqlserver调用WebApi
原文地址 http://www.cnblogs.com/lflyq/p/6065160.html sp_configure 'show advanced options', 1;GORECONFI ...
- 【前端】Html5浏览器缓存 sessionStorage 与 localStorage
一.sessionStorage: 浏览关闭会话结束就被清除:(不能跨页面) localStorage:永久保存: 二.使用 var storage = window.sessionStorage; ...