洛谷 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 ...
随机推荐
- Apache 工作模式配置优化
Apahce 工作模式配置 1.查看当前MPM工作模式 /usr/local/apache2/bin/apachectl -V Server version: Apache/2.4.27 (Unix) ...
- float 为什么可以表示很大的整数
1.float型:单精度浮点数在机内占4个字节,用32位二进制描述(注意:计算机中1个字节=8位). 2.浮点数在机内用指数型式表示,分解为:数符,尾数,指数符,指数四部分. 3.可以算出float型 ...
- 使用C语言扩展Python提供性能
python底层是用c写的,c本身是一个非常底层的语言,所以它做某些事情的效率肯定会比上层语言高一些. 比如有些自动化测试用的python库,会对系统的UI进行一些捕获,点击之类的操作,这必然要用到c ...
- install tabix/bgzip
bgzip – Block compression/decompression utility tabix – Generic indexer for TAB-delimited genome pos ...
- HUE中Oozie执行Hive脚本
Oozie执行hive,传入参数1. 新建一个workflow 2. 拖入一个hive2 3. hive脚本如下 CREATE TABLE IF NOT EXISTS spider_tmp.org_i ...
- windchill相关功能操作
1.创建产品 2.创建文件夹 3.创建文档 4.创建用户账号 5.创建组 6.创建更改请求 7.创建部件新视图版本 8.创建可重用属性和全局枚举 9.在组织内分配上下文 ...
- 利用OPENSSH自身记录密码
大家都知道,OPENSSH是基于Linux下,一款开源,安全性不错的Linux SSH会话连接工具. 在渗透当中,当我们get root了.我们如何来记录Linux管理员登陆过的SSH? 想法如下: ...
- 报错HTTP Status 500 - The given object has a null identifier: cn.itcast.entity.Customer; nested exception is org.hibernate.TransientObjectException: The given object has a null identifier:
在使用模型驱动封装的时候,要保证表单中name属性名和类中属性名一致,否则将会报错如下: HTTP Status 500 - The given object has a null identifie ...
- js 小复习1
1.数组 增删改查 , , , , ]; // arr.push(18); // 添加数组后面 更改长度 // arr.unshift(12); // 添加数组前面 // arr.pop(); // ...
- js的callee和caller方法
转载:http://www.css88.com/archives/1706 http://www.jb51.net/article/25561.htm 这里我们可以知道: caller的使用方法: f ...