[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: ...
随机推荐
- Unity Transform常识(转)
Variables position: Vector3 物体在世界坐标中的位置. transform.position=Vector3(10,10,10)//把物体放到(x=10,y=10,z= ...
- Springboot 配置 application.yml 连接MySQL数据库
1.在pom.xml的<dependencies></dependencies>标签中中加入以下依赖 <dependency> <groupId>org ...
- jQuery同时监听两个事件---实现同时操控两个按键
我们都知道因为js是单线程的,所以没有可以同时触发键盘两个事件的方法 今天我们就来做一个可以实现这个功能方法 先来看一下成品图效果 接下来我们来看下具体是怎么实现的 注释写在了代码里面 <!DO ...
- 揭开Python科学计算的面纱
春牛春杖.无限春风来海上.便与春工.染得桃红似肉红. 春幡春胜.一阵春风吹酒醒.不似天涯.卷起杨花似雪花. 标准的Python中用列表保存一组值,可以当做数组使用,但是由于其值类型任意,所以列表中保存 ...
- UvaLive6442(思维、结论)
结论是:按位置排序好以后,对于真正的答案,走法应该是:依次走向第0个等分点,第1个等分点……这样对于这种等分情况,是最优的调度. /* 先假设一个终点位置然后按位站好 这个位置不一定是最优所以要调 调 ...
- Hibernate Could not obtain transaction-synchronized Session for current thread问题处理
项目通过Hibernate查询时报出如下错误: Hibernate Could not obtain transaction-synchronized Session for current thre ...
- iphone6,键盘收起,H5页面下面出现空白
- html2canvas如何将div转成图片并下载,如何将滚动条的内容截取下来
<!DOCTYPE html> <html lang="en"> <head> <meta name="layout" ...
- Myisamchk使用
Myisam损坏的情况: . 服务器突然断电导致数据文件损坏;强制关机,没有先关闭mysql 服务;mysqld 进程在写表时被杀掉.因为此时mysql可能正在刷新索引. . 磁盘损坏. . 服务器死 ...
- servlet service的描述:
链接:https://www.nowcoder.com/questionTerminal/3f368578e43d48b1968d79b935d00972来源:牛客网 1. service方法 ...