洛谷 P2920 [USACO08NOV]时间管理Time Management
题目大意:
每个工作有截至时间和耗费时间,n个工作求最小开始时间。
题解:
贪心
从n-1安排,让结束时间尽量的晚。
注意:优先级
cout<<st<0?-1:st; (X)
cout<<(st<0?-1:st);'
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 1090
using namespace std; int n,st; struct T{
int t,s;
}w[N]; bool cmp(T a,T b){
return a.s>b.s;
} int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)scanf("%d%d",&w[i].t,&w[i].s);
sort(w+,w+n+,cmp);
st=w[].s-w[].t;
for(int i=;i<=n;i++){
int ed=min(w[i].s,st);
st=ed-w[i].t;
}
//printf("%d\n",st<0?-1:st);
cout<<(st<?-:st);
return ;
}
洛谷 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 ...
- [LUOGU] P2920 [USACO08NOV]时间管理Time Management
见7.3测试 #include<iostream> #include<algorithm> #include<cstdio> using namespace std ...
- 题解 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 ...
- 洛谷 P2146 [NOI2015]软件包管理器
真没有想到,这竟然会是一道NOI的原题,听RQY说,这套题是北大出的,北大脑抽认为树剖很难... 只恨没有早学几年OI,只A这一道题也可以出去吹自己一A了NOI原题啊 好了,梦该醒了,我们来看题 以后 ...
- 洛谷P2916 [USACO08NOV]为母牛欢呼(最小生成树)
P2916 [USACO08NOV]为母牛欢呼Cheering up the C… 题目描述 Farmer John has grown so lazy that he no longer wants ...
- 洛谷P2826 [USACO08NOV]光开关Light Switching [2017年6月计划 线段树02]
P2826 [USACO08NOV]光开关Light Switching 题目描述 Farmer John tries to keep the cows sharp by letting them p ...
随机推荐
- SpringBoot AOP控制Redis自动缓存和更新
导入redis的jar包 <!-- redis --> <dependency> <groupId>org.springframework.boot</gro ...
- VRChat简易教程2-创建一个最基本的世界(world)
一.准备工作 1 先确保你安装了unity并导入了sdk 教程:https://www.cnblogs.com/cation/p/10311702.html 2 按之前的教程新建一个project并导 ...
- 20145222黄亚奇《网络对抗》- shellcode注入&Return-to-libc攻击深入
20145222黄亚奇<网络对抗>- shellcode注入&Return-to-libc攻击深入 shellcode注入实践过程
- 《Python学习手册》(四)
List and Dictionary 列表: 任意对象的有序集合 通过偏移读取 可变.异构.任意嵌套 常用方法: L.append(object) L.extend(iterable) L.inse ...
- UVA 725 UVA 10976 简单枚举
UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件 ...
- 微信小程序选择器
- MySql 存储过程实例 - 转载
MySql 存储过程实例 将下面的语句复制粘贴可以一次性执行完,我已经测试过,没有问题! MySql存储过程简单实例: ...
- gitlab 卸载
gitlab 卸载 清理命令 sudo gitlab-ctl uninstall sudo gitlab-ctl cleanse sudo gitlab-ctl remove-accounts 停止g ...
- Ubuntu 通过APT安装Tomcat
Ubuntu 通过APT安装Tomcat 安装 sudo apt-get install tomcat8 tomcat8-docs tomcat8-examples tomcat8-admin # s ...
- scala学习手记16 – scala中的static
前面两节学了scala的对象和伴生对象,这两个在使用的时候很有些java的静态成员的意思. scala中没有静态字段和静态方法.静态成员会破坏scala所支持的完整的面向对象模型.不过可以通过伴生对象 ...