考试排名
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8831 Accepted Submission(s): 3070
我们做好了题目的解答,提交之后,要么“AC”,要么错误,不管怎样错法,总是给你记上一笔,表明你曾经有过一次错误提交,因而当你一旦提交该题“AC”后,就要与你算一算帐了,总共该题错误提交了几回。虽然你在题数上,大步地跃上了一个台阶,但是在耗时上要摊上你共花去的时间。特别是,曾经有过的错误提交,每次都要摊上一定的单位时间分。这样一来,你在做出的题数上,可能领先别人很多,但是,在做出同样题数的人群中,你可能会在耗时上处于排名的劣势。
例如:某次考试一共8题(A,B,C,D,E,F,G,H),每个人做的题都在对应的题号下有个数量标记,负数表示该学生在该题上有过的错误提交次数,但到现在还没有AC,正数表示AC所耗的时间,如果正数a跟上一对括号,里面有个整数b,那就表示该学生提交该题AC了,耗去了时间a,同时,曾经错误提交了b次,因此对于下述输入数据:
若每次错误提交的罚分为20分,则其排名从高到低应该是这样的:
Josephus 5 376
John 4 284
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0
8 20 Smith -1 -16 8 0 0 120 39 0 John 116 -2 11 0 0 82 55(1) 0 Josephus 72(3) 126 10 -3 0 47 21(2) -2 Bush 0 -1 -8 0 0 0 0 0 Alice -2 67(2) 13 -1 0 133 79(1) -1 Bob 0 0 57(5) 0 0 168 -7 0
Josephus 5 376 John 4 284 Alice 4 352 Smith 3 167 Bob 2 325 Bush 0 0
#include<iostream>
#include<iomanip>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct stu{
int AC,time;
string name;
};
int cmp(stu a,stu b){
if(a.AC == b.AC)
{
if(a.time == b.time)
{
return a.name < b.name;
}
return a.time < b.time;
}
return a.AC > b.AC;
}
int main()
{
int n,m,i,j,k,score;
stu test[10000];
string str_name;
cin>>n>>m;
for(k = 0;cin>>str_name;k++)
{
test[k].name = str_name;
test[k].AC = 0;
test[k].time = 0;
for(i = 0;i < n;i++)
{
cin>>score;
if(score <= 0) continue;
test[k].AC++;
test[k].time += score;
if(getchar() == '(')
{
cin>>score;
test[k].time += score*m;
getchar();
}
}
}
sort(test,test+k,cmp);
for(i = 0;i < k;i++)
{
cout<<left<<setw(10)<<test[i].name<<' ';
cout<<right<<setw(2)<<test[i].AC<<' ';
cout<<right<<setw(4)<<test[i].time<<endl;
}
return 0;
}
2191



被折叠的 条评论
为什么被折叠?



