没有什么弯路,直接模拟即可。水题。
1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #include <cmath> 6 #include <cctype> 7 #include <algorithm> 8 #include <numeric> 9 using namespace std; 10 11 struct team { 12 string name; 13 int submit[4], time[4]; 14 int ac , time_all ; 15 void setTeam (string n, int s1, int t1, int s2, int t2, int s3, int t3, int s4, int t4) { 16 name = n; 17 ac = 0; time_all = 0; 18 submit[0] = s1; time[0] = t1; 19 submit[1] = s2; time[1] = t2; 20 submit[2] = s3; time[2] = t3; 21 submit[3] = s4; time[3] = t4; 22 for (int i = 0; i < 4; ++ i) { 23 if (submit[i] > 0 && time[i] > 0) { 24 ac ++; 25 time_all += time[i] + 20 * (submit[i] - 1 ); 26 } 27 } 28 } 29 }; 30 31 bool cmp (team a, team b) { 32 if (a.ac != b.ac) { 33 return a.ac > b.ac; 34 } else { 35 return a.time_all < b.time_all; 36 } 37 } 38 39 int main () { 40 ios :: sync_with_stdio(false); 41 int n; team Team[100]; 42 string name; int s1, s2, s3, s4, t1, t2, t3, t4; 43 while (cin >> n) { 44 for (int i = 0; i < n; ++ i) { 45 cin >> name >> s1 >> t1 >> s2 >> t2 >> s3 >> t3 >> s4 >> t4; 46 Team[i].setTeam(name, s1, t1, s2, t2, s3, t3, s4, t4); 47 } 48 sort (Team, Team + n, cmp); 49 cout << Team[0].name << " " << Team[0].ac << " " << Team[0].time_all << endl; 50 } 51 return 0; 52 }