[Water]UVA 11792 Commando War

 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;

}

  

你可能感兴趣的:(command)