洛谷 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 ...
随机推荐
- 20145109 《Java实验报告1》
Experiment Ⅰ --getting familiar with JDK (Linux + Eclipse) Content 1.Compile and run easy Java progr ...
- React 学习参考资料链接
node.js官网https://nodejs.org/en/download/ React 入门实例教程http://www.ruanyifeng.com/blog/2015/03/react.ht ...
- 20 个 OpenSSH 最佳安全实践
来源:https://linux.cn/article-9394-1.html OpenSSH 是 SSH 协议的一个实现.一般通过 scp 或 sftp 用于远程登录.备份.远程文件传输等功能.SS ...
- java分页的实现(后台工具类和前台jsp页面)
1.首先,新建一个类Page.java public class Page implements Serializable { private static final long serialVers ...
- Text Justification,文本对齐
问题描述:把一个集合的单词按照每行L个字符放,每行要两端对齐,如果空格不能均匀分布在所有间隔中,那么左边的空格要多于右边的空格,最后一行靠左对齐. words: ["This", ...
- ACM-ICPC北京站总结
失踪人口回归.... 第一次ACM比赛还是比较紧张的,总体来说发挥还是有一点失常. day1热身赛 一共四道去年和前年的北京站的题目....似乎都是银牌题及以下难度.半个小时我们就完成了嘴巴AK,然而 ...
- hdu 5978 To begin or not to begin(概率,找规律)
To begin or not to begin Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java ...
- 在SQL Server中快速删除重复记录
在SQL Server中快速删除重复记录 2006-07-17 21:53:15 分类: SQL Server 开发人员的噩梦——删除重复记录 想必每一位开发人员都有过类似的经历,在对数据库进行查询 ...
- canvas - 饼状图
<!DOCTYPE html> <html> <head> <title>Canvas测试</title> <meta charset ...
- C#基础知识梳理系列
1. 这个系列深入的从IL层面谈了C#各种基本知识的本质,十分值得学习: http://www.cnblogs.com/solan/category/398748.html