HDU 1084 [What is Your Grade?] struct sort

Source: Internet
Author: User

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&LT;B.S:A.M&LT;B.M): a.h<b.h): A.N&GT;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", &AMP;E[I].N,&AMP;E[I].H,&AMP;E[I].M,&AMP;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&LT;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.