现在的位置: 首页 > 综合 > 正文

HDOJ 1236

2013年07月22日 ⁄ 综合 ⁄ 共 1183字 ⁄ 字号 评论关闭
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int MAXSTUDENT=1000;
const int MAXPROBLEM=10;
class student
{
public:
	string ID;
	int total;
	int pro_solved;
	bool operator<(const student &v2) const;
};
bool student::operator<(const student &v2) const
{
	if(total>v2.total||(total==v2.total&&ID<v2.ID))
		return true;
	else
		return false;
}


int main()
{
	int stuNumber,proNumber,scoreLine;
	while(cin>>stuNumber&&stuNumber)
	{
		student students[MAXSTUDENT];
		for(int i=0;i<MAXSTUDENT;++i)
		{
			students[i].ID=" ";
			students[i].pro_solved=0;
			students[i].total=0;
		}
		int pointEachPro[MAXPROBLEM];
		for(int i=0;i<MAXPROBLEM;++i)
		{
			pointEachPro[i]=0;
		}
		cin>>proNumber>>scoreLine;
		for(int ix=0;ix<proNumber;++ix)
		{
			cin>>pointEachPro[ix];
		}
		
		int crosstheLine=0;
		for(int ix=0;ix<stuNumber;++ix)
		{
			cin>>students[crosstheLine].ID>>students[crosstheLine].pro_solved;
			students[crosstheLine].total=0;
			for(int j=0;j<students[crosstheLine].pro_solved;++j)
			{
				int whichIsSolved;
				cin>>whichIsSolved;
				students[crosstheLine].total+=pointEachPro[whichIsSolved-1];
			}
			if(students[crosstheLine].total>=scoreLine)
				++crosstheLine;
			
		}
		sort(students,students+crosstheLine);
		cout<<crosstheLine<<endl;
		for(int ix=0;ix<crosstheLine;++ix)
			cout<<students[ix].ID<<" "<<students[ix].total<<endl;
	}
}

抱歉!评论已关闭.