zoukankan      html  css  js  c++  java
  • HDU1177:"Accepted today?"

    Problem Description
    Do you remember a sentence "Accepted today?" Yes, the sentence is mentioned frequently in lcy's course "ACM Programming"!
    The contest is still in progress this moment. How excited it is! You, smart programmer, must have AC some problems today. "Can I get copper medal, silver medal, or even golden medal?" Oh, ha-ha! You must be considering this question. And now, the last problem of this contest comes.
    Give you all submitting data in the contest, and tell you the number of golden medals, silver medals and copper medals; your task is to output someone's contest result.
    Easy? Of course! I t is the reason that I designed the problem.
    When you have completed this contest, please remember that sentence〃 Accepted today?〃兒
     
    Input
    Input contains multiple test cases. Each test case starts with five numbers N (4 =< N <= 130 -- the total number of attendees), G, S, C (1<=G<=S<=C<N --G, S, C denoting the number of golden medals, silver medals and copper medals respectively) and M (0<M<=N). The next N lines contain an integer P (1<=P<=8 --number of problems that have been solved by someone) and a time T(for example,"02:45:17", meaning 2 hours and 45 minutes and 17 seconds consumed according to contest rules) each. You can assume that all submit data are different.
    A test case starting with 0 0 0 0 0 terminates input and this test case should not to be processed.
     
    Output
    For each case, print a sentence in a line, and it must be one of these sentences:
    Accepted today? I've got a golden medal :)
    Accepted today? I've got a silver medal :)
    Accepted today? I've got a copper medal :)
    Accepted today? I've got an honor mentioned :)

    Note:  
    You will get an honor mentioned if you can't get copper medal, silver medal or golden medal.
     
    Sample Input
    10 1 2 3 6 2 02:45:17 2 02:49:01 2 03:17:58 2 03:21:29 4 07:55:48 3 04:25:42 3 06:57:39 2 02:05:02 2 02:16:45 2 02:41:37 0 0 0 0 0
     


     

    简单排序

    #include <stdio.h>
    #include <algorithm>
    using namespace std;
    
    struct AC
    {
        int num,h,m,s;
        int no;
        int k;//k=1金,2银,3铜,4,安慰奖
    } a[200];
    
    int cmp(AC x,AC y)
    {
        if(x.num!=y.num)
        return x.num>y.num;
        if(x.h!=y.h)
        return x.h<y.h;
        if(x.m!=y.m)
        return x.m<y.m;
        return x.s<y.s;
    }
    
    int main()
    {
        int n,g,s,c,m,i;
        while(~scanf("%d%d%d%d%d",&n,&g,&s,&c,&m))
        {
            if(n+g+s+m+c == 0)
                break;
            for(i = 0; i<n; i++)
            {
                a[i].no = i+1;
                scanf("%d %d:%d:%d",&a[i].num,&a[i].h,&a[i].m,&a[i].s);
            }
            sort(a,a+n,cmp);
            //printf("====\n");
            for(i = 0; i<n; i++)
            {
                if(g)
                {
                    a[i].k = 1;
                    g--;
                }
                else if(s)
                {
                    a[i].k = 2;
                    s--;
                }
                else if(c)
                {
                    a[i].k = 3;
                    c--;
                }
                else
                {
                    a[i].k = 4;
                }
            }
            for(i = 0; i<n; i++)
            {
                if(a[i].no == m)
                {
                    if(a[i].k == 1)
                        printf("Accepted today? I've got a golden medal :)\n");
                    else if(a[i].k == 2)
                        printf("Accepted today? I've got a silver medal :)\n");
                    else if(a[i].k == 3)
                        printf("Accepted today? I've got a copper medal :)\n");
                    else if(a[i].k == 4)
                        printf("Accepted today? I've got an honor mentioned :)\n");
                    break;
                }
            }
        }
    
        return 0;
    }
    


     

  • 相关阅读:
    GB/T 38879-2020 颗粒 粒度分析 彩色图像分析法
    GB/T 30431-2020 实验室气相色谱仪
    GB/T 50165-2020 古建筑木结构维护与加固技术标准
    GB/T 51405-2019 船厂总体设计标准
    GB/T 38922-2020 35kV及以下标准化继电保护装置通用技术要求
    GB/T 38953-2020 微电网继电保护技术规定
    GB/T 38886-2020 高温轴承钢等最新国家标准(2020-6-19)
    pytest_02(使用pychar执行pytest)
    pytest-01(安装pytest及运行规则)
    python-05(关于map函数的使用)
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3106642.html
Copyright © 2011-2022 走看看