杭电ACM Step 1.3.3就是无法AC,求大牛帮忙
题目来源:http://acm.hdu.
或者各位有源码,发来也行,最好有注释,谢!
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
struct pm{ char s[21]; int c;};bool push(pm a,pm b)
{
if(a.c!=b.c)
return a.c>b.c;
else if(strcmp(a.s,b.s))
return true;
else return false;
}
int main()
{
int people,pro,scolin;//参赛人数,问题数,分数线
int prosco[10];//每题分数
char s[21];
int correct,sco,scosum,peosum;
vector<pm>v;
pm q;
int i,j;
while(cin>>people)
{
if(people==0)
break;
peosum=0;
cin>>pro>>scolin;
for(i=0;i<pro;i++)
{
cin>>prosco[i];
}
for(i=0;i<people;i++)
{
scosum=0; cin>>s>>correct;//学号,通过的题数
for(j=0;j<correct;j++)
{
cin>>sco; scosum+=prosco[sco-1];
}
if(scosum>=scolin)
{
peosum++;
strcpy(q.s,s);
q.c=scosum;
v.push_back(q);
}
}
cout<<peosum<<endl;
sort(v.begin(),v.end(),push);
for(i=0;i<v.size();i++)
cout<<v[i].s<<' '<<v[i].c<<endl;
v.clear();
}
return 0;
}