Hdoj what is your grade?

Source: Internet
Author: User

Question:

 
Problem description "point, point, life of Student !"
This is a balglad (Song) well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.
There are 5 problems in this final exam. and I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for your. if you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former (former) only when your rank is in the first half of all students who solve 4 problems ). analogically (and so on), you can get 85, 80, 75, 70, 65, 60. but you will not pass this exam if you solve nothing problem, And I will mark your score with 50.
Note, only 1 student will get the score 95 When 3 students have solved 4 problems.
I wish you all can pass the exam!
Come on!
Inputinput contains multiple test cases. each test case contains an integer N (1 <= n <= 100, the number of students) in a line first, and then n lines follow. each line contains P (0 <= P <= 5 number of problems that have been solved) and T (consumed time ). you can assume that all data are different when 0 <p.
A test case starting with a negative integer terminates the input and this test case shocould not to be processed.
Outputoutput the scores of N students in n lines for each case, and there is a blank line after each case.
Sample Input
45 06:30:174 07:31:274 08:12:124 05:23:1315 06:30:17-1
 
Sample output
100909095100

A simple question ...... First, sort the tasks based on the time consumption and the number of questions to be solved, and then convert the scores based on the question requirements. Here, the order of the IF Statements reversed and I submitted them several times before ac...

Finally, sort the output according to the input position...

Writing is a little troublesome.

#include "stdafx.h"#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;struct Student{    int p;    string s;    int grade;    int order;};bool cmp(const Student&a,const Student&b){    if(a.p!=b.p)        return a.p>b.p;    else        return a.s<b.s;}bool cmp2(const Student&a,const Student&b){    return a.order<b.order;}int main(){    int n;    while(scanf_s("%d",&n)&&n>0)    {        vector<Student> t;        Student temp;        int k=n;        temp.p=100;        t.push_back(temp);        int j=0;        int count[6]={0};        while(n--)        {            cin>>temp.p>>temp.s;            temp.order=j++;            t.push_back(temp);                    }        sort(t.begin()+1,t.end(),cmp);        //temp.p=100;        //t.push_back(temp);        for (int i = 1; i < k+1; i++)        {            count[t[i].p]++;        }        for (int i = 0; i < 6; i++)        {            count[i]==1?count[i]=-5:count[i]/=2;        }        for (int i = 1; i < k+1; i++)        {            if(count[t[i].p]==-5)                t[i].grade=50+t[i].p*10+5;            if (count[t[i].p]==0)            {                t[i].grade=50+t[i].p*10;            }            if(count[t[i].p]>0)            {                t[i].grade=50+t[i].p*10+5;                count[t[i].p]--;            }            if(t[i].p==5||t[i].p==0)                t[i].grade=50+t[i].p*10;            }        sort(t.begin()+1,t.end(),cmp2);        for (int i = 1; i < k+1; i++)        {            cout<<t[i].grade<<endl;        }        cout<<endl;    }    return 0;}

 

Hdoj what is your grade?

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.