【POJ1581】A Contesting Decision(简单模拟)

时间:2021-01-23 15:04:09

没有什么弯路,直接模拟即可。水题。

 #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <numeric>
using namespace std; struct team {
string name;
int submit[], time[];
int ac , time_all ;
void setTeam (string n, int s1, int t1, int s2, int t2, int s3, int t3, int s4, int t4) {
name = n;
ac = ; time_all = ;
submit[] = s1; time[] = t1;
submit[] = s2; time[] = t2;
submit[] = s3; time[] = t3;
submit[] = s4; time[] = t4;
for (int i = ; i < ; ++ i) {
if (submit[i] > && time[i] > ) {
ac ++;
time_all += time[i] + * (submit[i] - );
}
}
}
}; bool cmp (team a, team b) {
if (a.ac != b.ac) {
return a.ac > b.ac;
} else {
return a.time_all < b.time_all;
}
} int main () {
ios :: sync_with_stdio(false);
int n; team Team[];
string name; int s1, s2, s3, s4, t1, t2, t3, t4;
while (cin >> n) {
for (int i = ; i < n; ++ i) {
cin >> name >> s1 >> t1 >> s2 >> t2 >> s3 >> t3 >> s4 >> t4;
Team[i].setTeam(name, s1, t1, s2, t2, s3, t3, s4, t4);
}
sort (Team, Team + n, cmp);
cout << Team[].name << " " << Team[].ac << " " << Team[].time_all << endl;
}
return ;
}