Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1084
The main topic: a total of 5 questions, n students. Make 5 full marks, 0 lanes and 50 points. The students who make 1-4-way, if the first 50% (rounding down), then get 95, 85, 75, 65, if in the latter 50% will be 90, 80, 70, 60.
Key IDEAS: Structure sequencing
Structure sorting, consider boundary #include <iostream> #include <algorithm> #include <cmath> #include <memory.h> Using namespace std;struct node{int id;int n;int h,m,s;int score;} E[102];int C[6]; Save the number of people who made the I question bool CMPs (node A,node b) {return A.N==B.N? A.h==b.h? (A.M==B.M?A.S<B.S:A.M<B.M): a.h<b.h): A.N>B.N;} Sort by title bool Cmpid (node A,node b) {return a.id<b.id;} sort int main () {int N,cnt;while (cin>>n&&n!=-1) {memset (e,0,sizeof (e)) by input ID order, memset (C,0,sizeof (c)); for (int i=0;i<n;i++) {e[i].id=i;scanf ("%d%d:%d:%d", &E[I].N,&E[I].H,&E[I].M,&E[I].S); C[E[I].N] ++;} Sort (e,e+n,cmps); cnt=0;for (int j=0;j<c[5];j++) {e[cnt+j].score=100;} cnt+=c[5];for (int k=4;k>0;k--) {for (int j=0;j<c[k];j++) {if (J<C[K]/2) e[cnt+j].score=50+5* (2*k+1); else e[ Cnt+j].score=50+10*k;} cnt+= (C[k]);} for (int j=0;j<c[0];j++) {e[cnt+j].score=50;} Sort (e,e+n,cmpid); for (int i=0;i<n;i++) Cout<<e[i].score<<endl;cout<<endl;} return 0;}
HDU 1084 [What is Your Grade?] struct sort