Problem Description
Submit real-time test used C ++ programming system with features instant access to Scores. Its function is how to achieve it?
We answer questions well, and after the submission, or "AC", or error, and error in any case, always remember you in on a show that you have had a bad commit, so as soon as you submit the title " after AC ", we must reckon with the account, for a total error of the questions submitted several times. While you're on the number of questions, strode leapt to a new level, but stalls on the time-consuming for the time you spent a total. In particular, there have been errors committed, stalls every time a certain unit of time points. As a result, the number of questions you made, may lead many others, however, the crowd make the same number of questions, you may be at a disadvantage in the rankings consuming.
For example: a test as a total of eight questions (A, B, C, D , E, F, G, H), each made questions are to have a number of markers in question number corresponding to the negative means the student the title there have been submitted on the wrong times, but until now no AC, AC positive number indicates that the consumption of time, if a positive number to keep up with a pair of parentheses, which has integer b, it means the student has to submit the question of the AC , consumes a time a, while the error has submitted b times, so for the following input data:
If each of the dates penalty of 20 minutes, it should be such that the ranking from high to low:
Josephus. 5 376 is
4 284 john
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0
We answer questions well, and after the submission, or "AC", or error, and error in any case, always remember you in on a show that you have had a bad commit, so as soon as you submit the title " after AC ", we must reckon with the account, for a total error of the questions submitted several times. While you're on the number of questions, strode leapt to a new level, but stalls on the time-consuming for the time you spent a total. In particular, there have been errors committed, stalls every time a certain unit of time points. As a result, the number of questions you made, may lead many others, however, the crowd make the same number of questions, you may be at a disadvantage in the rankings consuming.
For example: a test as a total of eight questions (A, B, C, D , E, F, G, H), each made questions are to have a number of markers in question number corresponding to the negative means the student the title there have been submitted on the wrong times, but until now no AC, AC positive number indicates that the consumption of time, if a positive number to keep up with a pair of parentheses, which has integer b, it means the student has to submit the question of the AC , consumes a time a, while the error has submitted b times, so for the following input data:
If each of the dates penalty of 20 minutes, it should be such that the ranking from high to low:
Josephus. 5 376 is
4 284 john
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0
Input
The first line of input data is the number of test questions n (1≤n≤12) and unit penalty number m (10≤m≤20), each row describes a user name student (no more than 10 characters in the string ) and of all n status answer questions, which describes the format described in the number of questions marks, see the table above, is always less than the number filed 100, AC 1000 is always less than the time spent.
Output
The status of the examination of these students, the output of a real-time ranking. Real-time ranking is obviously the question of how much the number of AC press row, more than the former, then how much time points row, small front before happened if both are equal, press the name of lexicographical row, smallest first . Each student per line, output the name (10 characters wide), the number of questions to make (2 characters wide, right-justified) and time points (four characters wide, right-justified). Name, title and the number of time points there is a space between each other.
Sample Input
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
Sample Output
Josephus 5 376
John 4 284
Alice 4 352
Smith 3 167
Bob 2 325
Bush 0 0
Ideas: String Analog plus sorting, basic questions, over and over low-key low-key ......
1 #include<iostream>
2 #include<cstring>
3 #include<cstdio>
4 #include<cmath>
5 #include<algorithm>
6 #include<map>
7 #include<set>
8 #include<vector>
9 #include<queue>
10 using namespace std;
11 #define ll long long
12 const int mod=1e9+7;
13 const int inf=1e9+7;
14
15 typedef struct
16 {
. 17 String name; // name
18 is int the AC; // the AC number of questions
. 19 int Penalty; // time penalty
20 is } St;
21 is
22 is Vector <St> V; // taking into account the number of uncertainty, with a variable length structure body array (STl really fragrant)
23
24- BOOL cmp ( const St & A, const St & b) // press questions intended to write cmp function
25 {
26 IF (a.AC! = b.AC) // AC number of different questions
27 return A .AC> b.AC; // number of questions more than the top
28 the else// the AC same number of questions
29 {
30 IF (a.penalty = b.penalty!) // when different penalty
31 is return a.penalty <b.penalty; // less penalty when the top
32 the else // same time penalty
33 return a.name <b.name; // name of the former small lexicographically position (parallel reason it should orzorz)
34 is }
35 }
36
37 [ int main ()
38 is {
39 // iOS :: sync_with_stdio (to false); CIN. TIE (0); cout.tie (0);
40
41 is int n, time; // the n-th title penalty
42 is
43 is n >> >> CIN Time;
44 is
45 String ID; // name
46 is
47 St now; // definition of a structure that each input name data record
48 String STR; // case where problem processing the n
49
50 the while (CIN >> ID) // write EOF end of the file will be read out of the loop can debug its own press ctrl + z manually exit
51 is {
52 is now.name ID =; // save the name
53 is int ANS = 0 ; // calculation when penalty
54 is int AC = 0 ; // calculate the number of AC
55 for (int I = 0 ; I <n-; I ++ )
56 is {
57 is CIN >> STR; // read the title of each case
58 IF (STR [ 0 ] == ' - ' || STR == " 0 " ) // do not make || not, skip
59 the Continue ;
60 AC ++; // or certainly the AC
61 IF (str.find ( " ( " ) = -! 1 ) // find the brackets
62 {
63 int Place1 = str .find (" ( " );
64 int Place2 = str.find ( " ) " );
65 ANS + = Stoi (str.substr ( 0 , Place1)); // calculating two penalty
66 ANS + = Stoi (str.substr (Place1 + . 1 , Place2-place1- . 1 )) * time;
67 }
68 the else
69 {
70 ANS + = Stoi (STR); // no penalty when a bracket
71 is }
72 }
73 is now.AC = AC; // save the number of AC
74 now.penalty = ANS; // when stored penalty
75 v.push_back (now); // introducing structural array
76 }
77
78 Sort (v.begin (), v.end (), CMP); // Press It is intended to sort title
79
80 for ( int I = 0 ; I <v.size (); I ++ )
81 { // output format
82 the printf ( " % -10S% 2D 4D% \ n- " , V [I] .name. the c_str (), V [I] .AC, V [I] .penalty);
83 }
84
85 return 0 ;
86 }