传送门 题目大意: 每个工作有截至时间和耗费时间,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…
P2920 [USACO08NOV]时间管理Time Management 显然的贪心. 按deadline从大到小排序,然后依次填充时间. 最后时间为负的话那么就是无解 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define re register using namespace std; int max(int a,int b){return a&…
P2920 [USACO08NOV]时间管理Time Management 题目描述 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 ba…
见7.3测试 #include<iostream> #include<algorithm> #include<cstdio> using namespace std; ; inline int rd(){ ,f=;char c; :; +c-',c=getchar(); return ret*f; } struct Node{ int lon,tim; }nodes[MAXN]; bool cmp(const Node &x,const Node &y)…
题面 作为一名忙碌的商人,约翰知道必须高效地安排他的时间.他有N工作要 做,比如给奶牛挤奶,清洗牛棚,修理栅栏之类的. 为了高效,列出了所有工作的清单.第i分工作需要T_i单位的时间来完成,而 且必须在S_i或之前完成.现在是0时刻.约翰做一份工作必须直到做完才能停 止. 所有的商人都喜欢睡懒觉.请帮约翰计算他最迟什么时候开始工作,可以让所有工作按时完成.(如果无法完成全部任务,输出-1) 题意 有一个人有N项工作,给N组数据,每组数据有Ti和Si,分别表示第i组工作需要花费的时间和最晚完成的时…
题目描述 作为一名忙碌的商人,约翰知道必须高效地安排他的时间.他有N工作要 做,比如给奶牛挤奶,清洗牛棚,修理栅栏之类的. 为了高效,列出了所有工作的清单.第i分工作需要T_i单位的时间来完成,而 且必须在S_i或之前完成.现在是0时刻.约翰做一份工作必须直到做完才能停 止. 所有的商人都喜欢睡懒觉.请帮约翰计算他最迟什么时候开始工作,可以让所有工作按时完成.(如果无法完成全部任务,输出-1) 输入输出格式 输入格式: * Line 1: A single integer: N * Lines…
题目描述 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…
真没有想到,这竟然会是一道NOI的原题,听RQY说,这套题是北大出的,北大脑抽认为树剖很难... 只恨没有早学几年OI,只A这一道题也可以出去吹自己一A了NOI原题啊 好了,梦该醒了,我们来看题 以后放链接不放题面了,洛谷题面直接拷出来总是很迷 我是题面 读完题,我们会发现,这道题,好像是,树剖???裸题??? 没错,就是裸题 题目要求两种操作,先说第一种 安装程序\(x\),并输出修改状态的程序数目. 就是从\(x\)一直查询+更新到根节点呗,节点数目减去已安装的数目就是答案,先查询,再更新,…
P2916 [USACO08NOV]为母牛欢呼Cheering up the C… 题目描述 Farmer John has grown so lazy that he no longer wants to continue maintaining the cow paths that currently provide a way to visit each of his N (5 <= N <= 10,000) pastures (conveniently numbered 1..N).…
P2826 [USACO08NOV]光开关Light Switching 题目描述 Farmer John tries to keep the cows sharp by letting them play with intellectual toys. One of the larger toys is the lights in the barn. Each of the N (2 <= N <= 100,000) cow stalls conveniently numbered 1..N…