HDU 1236 排名

题目链接 http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=3&problemid=5


Description & Input & Output & Sample Input & Sample Output  (老规矩 请点链接 & 真的不是我懒_(:_」∠)_)


然后本来不想写这题的题解的,因为感觉写完之后没啥想写的,后来在网上翻其他人的题解都是用结构体,我个人觉得用make_pair更简单,就来这里贴一下代码。


/*
     HDU 1236
     测试结果 AC
	 By SHU_onisac 
*/

#include
#include
#include
#include
#include
#include
using namespace std;
#define INF 0x3FFFFFFF;
#define Rep(x,n) for(int x=0;x>n && n)
	{
	
		int flag=0;
		vector< pair >v;
		cin>>m>>g;
		Rep(i,m)cin>>M[i];
		Rep(i,n)
		{
			int mn;
			cin>>id;
			cin>>mn;
			Rep(j,mn)cin>>gra[j];
			int sum=0;
			Rep(j,mn)
			{
				int k;
				k=gra[j];
				k--;
				sum+=M[k];
			}
			if(sum>=g)
			{
				flag++;
				v.push_back(make_pair(-sum,id));
			}
		}
		if(flag==0)
		{
			cout<<0<


你可能感兴趣的:(ACM,杭电,acm,1236,排名,c++)