CDZSC_2015寒假新人(1)——基础 I

Description

“Point, point, life of student!” 
This is a ballad(歌谣)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 many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), 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!

Input

Input 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 should not to be processed.

Output

Output the scores of N students in N lines for each case, and there is a blank line after each case.

Sample Input

4

5 06:30:17

4 07:31:27

4 08:12:12

4 05:23:13

1

5 06:30:17

-1

Sample Output

100

90

90

95

100

思路:这题大概意思是解决5题可能拿100分,解决4题可以拿90或者95分(3 2 1题以此类推)(

你的排名排在班上解决了同样题数的同学中的前半部分可以拿95,例如解决4题的有4个,钱2个拿95,后两个拿90,5题,前两个拿95,后3个拿90)

),但一题也没做出来的50分(不及格哦T.T)。。。。用结构体存题数,时间,编号,成绩,然后排序(如果题数大的拍前面,相同的时间少排前面)。然后我再开一个结构体存该题目解决人数和每人解决该题数所用时间,通过如果时间小于等中间那个人的时间,那他的分数+5。然后通过编号再排序输出。。。。。

PS:陷阱(如果该题目解决的只有1人,他不会+5的)

我的测试样例:

4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
4 06:30:17
1
0 00:00:00
-1

100

90

90

95

90

50

代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct student
{
    int problem;
    int score;
    int time;
    int bianhao;
};
struct a
{
    int times[110];
    int count;
};
bool cmp(student stud1,student stud2)
{
    if(stud1.problem!=stud2.problem)
    {
        return stud1.problem>stud2.problem;
    }
    else
    {
        return stud1.time<stud2.time;
    }
}
bool cmp1(student stud1,student stud2)
{
    return stud1.bianhao<stud2.bianhao;
}
int main()
{
#ifdef CDZSC_OFFLINE
    freopen("in.txt","r",stdin);
#endif
    int n,i,h,m,s;
    student stud[110];
    a studs[6];
    while(scanf("%d",&n)&&n!=-1)
    {
        for(i=0; i<6; i++)
        {
            studs[i].count=0;
        }
        for(i=0; i<n; i++)
        {
            scanf("%d",&stud[i].problem);
            scanf("%d:%d:%d",&h,&m,&s);
            stud[i].time=h*3600+m*60+s;
            stud[i].score=50+10*stud[i].problem;
            stud[i].bianhao=i;
        }
        sort(stud,stud+n,cmp);
        for(i=0; i<n; i++)
        {
            studs[stud[i].problem].times[studs[stud[i].problem].count]=stud[i].time;
            studs[stud[i].problem].count++;
        }
        for(i=0; i<n; i++)
        {
            if(stud[i].problem!=5&&stud[i].problem!=0&&stud[i].time<=studs[stud[i].problem].times[studs[stud[i].problem].count/2-1])
            {
                stud[i].score+=5;
            }
        }
        sort(stud,stud+n,cmp1);
        for(i=0; i<n; i++)
        {
            printf("%d\n",stud[i].score);
        }
        printf("\n");
    }
    return 0;
}

时间: 2024-08-02 21:08:07

CDZSC_2015寒假新人(1)——基础 I的相关文章

CDZSC_2015寒假新人(1)——基础 B

Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor

CDZSC_2015寒假新人(1)——基础 D

Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.        Give you some integers, your task is to sort these number

CDZSC_2015寒假新人(1)——基础 G

Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the input is a s

CDZSC_2015寒假新人(1)——基础 E

Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that

CDZSC_2015寒假新人(1)——基础 F

Description An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting

CDZSC_2015寒假新人(1)——基础 C

Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.        The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds

CDZSC_2015寒假新人(1)——基础 H

Description Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him?        Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap ye

CDZSC_2015寒假新人(2)——数学 - O

Description 当寒月还在读大一的时候,他在一本武林秘籍中(据后来考证,估计是计算机基础,狂汗-ing),发现了神奇的二进制数. 如果一个正整数m表示成二进制,它的位数为n(不包含前导0),寒月称它为一个n二进制数.所有的n二进制数中,1的总个数被称为n对应的月之数. 例如,3二进制数总共有4个,分别是4(100).5(101).6(110).7(111),他们中1的个数一共是1+2+2+3=8,所以3对应的月之数就是8. Input 给你一个整数T,表示输入数据的组数,接下来有T行,每

CDZSC_2015寒假新人(4)——搜索 A

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and