标签:
题目链接: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+10; 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=1; while(cin>>n&&n) { RPE(i,n) cin>>b[i].x>>b[i].y; sort(b,b+n); int time=0; int Max=-1; RPE(i,n) { time+=b[i].x; Max=max(time+b[i].y,Max); } cout<<"Case "<<ca++<<": "<<Max<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/zsyacm666666/p/4796187.html