突击战 (UVA 11729)
2024-09-30 22:19:02
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=28436
思路:任务从开始时就不停执行,与其他任务毫无关联,当然是执行时间越长的任务越早执行好了
#include <iostream>
#include <algorithm>
#include <cstdio>
#define RPE(i,n) for(int i=0;i<n;i++)
using namespace std;
const int maxn=1e4+; struct node
{
public:
int x,y;
bool operator < (const node &another) const
{
return y>another.y;
}
}b[maxn]; int main()
{
ios::sync_with_stdio(false);
int n,ca=;
while(cin>>n&&n)
{
RPE(i,n) cin>>b[i].x>>b[i].y;
sort(b,b+n);
int time=;
int Max=-;
RPE(i,n)
{
time+=b[i].x;
Max=max(time+b[i].y,Max);
}
cout<<"Case "<<ca++<<": "<<Max<<endl;
}
return ;
}
最新文章
- 栈的C++实现(数组)——创建-push-pop-top-清空栈-处理栈
- [Android] 安卓模拟器临时文件相关问题
- 给Jquery添加alert,prompt方法,类似系统的Alert,Prompt,可以响应键盘,支持拖动
- poj 3083 Children of the Candy Corn (广搜,模拟,简单)
- rtems总结
- zend framework将zip格式的压缩文件导入并解压到指定文件
- 第七章——DMVs和DMFs(1)
- asp 301代码
- POJ1006-Biorhythms
- Js闭包应用场合,为vue的watch加上一个延迟器
- Python编程练习:使用 turtle 库完成六边形的绘制
- HDU - 1828 Picture
- Swift:playground
- .net core AOP之Filter
- 复杂PC问题——信号量与共享存储区
- RabbitMQ3.6.3集群搭建+HAProxy1.6做负载均衡
- Spring Data MongoDB 环境搭建
- PSROIAlign的代码实现
- TestNG执行测试用例的顺序
- 玩lua