HDU 2093 Exam Rankings
/*HDU 2093 Exam Rankings*/#include<cstdio>#include<string>#include<queue>#include<iostream>using namespacestd;structnode{stringname; intN; intUsetime; BOOL operator< (Constnode& RHS)Const { //sort from large to small first by value from N//I remember with RHS in the way before, with the RHS of the item and the current item comparison, big on the front if(RHS.N >N) { return 1; } Else if(RHS.N = =N) { //n equality is usetime from small to large sort if(Rhs.usetime <usetime)return 1; Else if(Rhs.usetime = =usetime) { //sort by name from small to large when all are equal if(Rhs.name <=name)return 1; Else return 0; } Else return 0; } Else return 0; }};p Riority_queue<Node>Q;intMain () {intN, M; intT, ch; scanf ("%d%d", &n, &m); Node tmp; while(Cin >>tmp.name) {Tmp.usetime=0; TMP.N=0; //Enter the score of n-Question for(inti =0; I < n; ++i) {scanf ("%d", &t); if(T >0){ ++TMP.N; Tmp.usetime+=T; if(ch = getchar ()) = ='(') {scanf ("%d", &t); Tmp.usetime+ = t*m; GetChar (); //eat ') ' } } }//For (i)Q.push (TMP); } while(!Q.empty ()) {tmp=q.top (); Q.pop (); printf ("%-10s%2d%4d\n", Tmp.name.c_str (), TMP.N, tmp.usetime); } return 0;}
View Code
HDU 2093 Exam Rankings