HDU 1236 排名

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


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


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


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

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define INF 0x3FFFFFFF;
#define Rep(x,n) for(int x=0;x<n;++x)
int main()
{
	int n,m,g;
	int M[15];
	string id;
	int gra[15];
	while(cin>>n && n)
	{
	
		int flag=0;
		vector< pair<int , string > >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<<endl;
			continue;
		}
		cout<<flag<<endl;
		sort(v.begin(),v.end());
		Rep(i,flag)cout<<v[i].second<<' '<<-1*v[i].first<<endl;
		
	}
	return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值