bzoj 1620: [Usaco2008 Nov]Time Management 时间管理(贪心)
1620: [Usaco2008 Nov]Time Management 时间管理
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 834 Solved: 527
[Submit][Status][Discuss]
Description
Ever the maturing businessman, Farmer John realizes that he must manage his time effectively. He has N jobs conveniently numbered 1..N (1 <= N <= 1,000) to accomplish (like milking the cows, cleaning the barn, mending the fences, and so on). To manage his time effectively, he has created a list of the jobs that must be finished. Job i requires a certain amount of time T_i (1 <= T_i <= 1,000) to complete and furthermore must be finished by time S_i (1 <= S_i <= 1,000,000). Farmer John starts his day at time t=0 and can only work on one job at a time until it is finished. Even a maturing businessman likes to sleep late; help Farmer John determine the latest he can start working and still finish all the jobs on time.
N个工作,每个工作其所需时间,及完成的Deadline,问要完成所有工作,最迟要什么时候开始.
Input
* Line 1: A single integer: N
* Lines 2..N+1: Line i+1 contains two space-separated integers: T_i and S_i
Output
* Line 1: The latest time Farmer John can start working or -1 if Farmer John cannot finish all the jobs on time.
Sample Input
Sample Output
按deline从小到大排序
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef struct Res
{int x, y;bool operator < (const Res &b) const{if(y<b.y)return 1;return 0;}
}Res;
Res s[100005];
int main(void)
{int n, i, sum, ans;scanf("%d", &n);for(i=1;i<=n;i++)scanf("%d%d", &s[i].x, &s[i].y);sort(s+1, s+n+1);ans = 10000000, sum = 0;for(i=1;i<=n;i++){sum += s[i].x;ans = min(ans, s[i].y-sum);}printf("%d\n", max(ans, -1));return 0;
}
bzoj 1620: [Usaco2008 Nov]Time Management 时间管理(贪心)相关推荐
- [BZOJ] 1620: [Usaco2008 Nov]Time Management 时间管理
1620: [Usaco2008 Nov]Time Management 时间管理 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 850 Solved ...
- Time Management 时间管理
Time Management 时间管理 世界上最快而又最慢,最长而又最短,最平凡而又最珍贵,最易被忽视而又最令人后悔的是什么? ------时间 ------接下来敢不敢完成挑战测试:你对时间的感知 ...
- bzoj 1618: [Usaco2008 Nov]Buying Hay 购买干草(完全背包)
1618: [Usaco2008 Nov]Buying Hay 购买干草 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1196 Solved: 62 ...
- bzoj 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场(DFS)
1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 913 Solv ...
- BZOJ 1619 [Usaco2008 Nov]Guarding the Farm 保卫牧场:dfs【灌水】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1619 题意: 给你一个n*m的地形图,位置(x,y)的海拔为h[x][y]. 一个山顶的定 ...
- BZOJ 1229: [USACO2008 Nov]toy 玩具
题意:就是经典餐巾问题 就是天数特别大 到了10^5 这道题弄了我好久啊,第一道三分题,不过好像三分并不难,我怕我讲不好,网上那么多我就不在这里说了. 网上面题解写的简直是太草率+简单了吧.坑爹的百度 ...
- 洛谷 P2920 [USACO08NOV]时间管理Time Management
时间管理Time Management 二分枚举开始时间. #include <iostream> #include <cstdio> #include <algorit ...
- 时间管理(Time Management)
什么是时间管理 时间管理是有效地运用时间,降低变动性. 时间管理的目的:决定什么事该做,什么事不该做. 时间管理最重要的功能:是透过事先的 规划,作为一种提醒与指引. 一.无法管理外在的要求 主管最大 ...
- 时间管理——你不可不知的3种时间管理方法
时间管理--你不可不知的3种时间管理方法 时间管理 英文名:Time Management 请问,如果每天都有86400元进入你的银行户头,而你必须当天用光,你会如何运用这笔钱? 天下真有这样的好事 ...
最新文章
- 从Request中获得当前请求的全路径
- 负离子发生器模块 ANION GENERATOR
- 64 DLL动态链接库换一台电脑就不能加载
- 速度优化_网站打开速度慢?如何优化?
- 安装paddlepaddle-GPU 报libcudnn.so和libcublas.so找不到的解决方案
- docker mysql数据库初始化_如何在Mysql的Docker容器启动时初始化数据库
- R+python︱XGBoost极端梯度上升以及forecastxgb(预测)+xgboost(回归)双案例解读
- java 反射 框架_Java——利用反射实现框架类
- 炒股高手必备抓大牛主图筹码箱体分析指标
- MPQ 文件系统完成
- c语言 结束360进程,python修改注册表终止360进程实例
- 从Otherside土地稀缺体系聊起, Yuga Labs到底在布局什么?
- 扎堆涌入“慢病管理”赛区,互联网医疗们看见了怎样的未来?
- 川大和哈工大计算机学院,哈尔滨工业大学计算机科学与技术学院
- java 实现dns劫持_JavaScript 防 http 劫持与 XSS
- 2021-03-13高级经理计算题:成本效益分析
- CentOS 消亡?不怕!替代发行版 AlmaLinux 获得商业支持
- 时序数据库:TimescaleDB的安装
- 转:以logistic Regression为例实现多类别分类及Python实现
- 程序员靠自己怎么赚钱?
热门文章
- python能做什么工作-python语言能做什么工作
- python编程教学软件-Python编程教学app
- python 下载文件-Python下载文件的方法
- python的第三方库是干什么用的-Python 常用的标准库以及第三方库有哪些?
- python读音有道-Python实现有道翻译+语音播报
- python3.6.5安装步骤-Ubuntu16.04安装python3.6.5步骤详解
- 如何找到靠谱的微信小程序,公众号H5开发外包,定制开发公司?
- 百度免费开放长语音识别功能
- 微信AI开放接口介绍
- 怎么二值化后找字_邓婕美肤团队:秋季皮肤出现问题后怎么办 找对护肤方法是关键_美肤吧...