首页 > 其他 > 详细

[Water]UVA 11792 Commando War

时间:2015-07-17 17:59:19      阅读:190      评论:0      收藏:0      [点我收藏+]

 n个部下,每个部下都要完成一个任务。每个任务需B时间交代,J时间执行。

不能同时给两个部下同时交代任务。

输出完成所有任务的最短时间。

//Uva 11792
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const int INF=0x3f3f3f3f;
const int MAXN=100;

struct job{
	int b,j;
	bool operator < (const job &a) const { 
        return j<a.j;//最大值优先 
    } 
};
int main()
{
	priority_queue<job>q;
	job temp;
	int n;
	int ct=1;
	while(cin>>n && n>0){
		while(!q.empty())q.pop();
		for(int i=0;i<n;++i){
			cin>>temp.b>>temp.j;
			q.push(temp);
		}
		int s=0,mmax=0;
		for(int i=0;i<n;++i){
			temp=q.top();
			//cout<<temp.b<<" ";
			s+=temp.b;
			mmax=max(mmax,s+temp.j);
			q.pop();
		}
		printf("Case %d: %d\n",ct++,mmax );
	}

	return 0;
}

  

[Water]UVA 11792 Commando War

原文:http://www.cnblogs.com/bruce27/p/4654803.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!