• Penalty


    Penalty
    时间限制:1000 ms | 内存限制:65535 KB
    难度:2
    描述
    As is known to us, the penalty is vitally important to competitors in the programming contest! After participating in the 2014 ACM-ICPC Asia Xian Regional Contest, LYH have a deep understanding about the importance of penalty. If some teams have solved same problem, the less penalty, the top rank.
    According to the rules of the competition, among all the teams, 10% will win a gold medal, 20% will win a silver medal, 30% will win a bronze medal. If it is not an integer, we will take the integer which not less than the real number as the number of the corresponding medal. For example, if the number of gold medal is 2.3, then we consider the number of gold medal is 3.
    For the sake of simpleness, suppose that the number of problems each team have solved is equal in the end of the programming contest, and we have known the penalty of each team. As a competitor , LYH want to know what is the maximum penalty will be if he wants to win a gold medal、a silver medal、a bronze medal.
    输入
    The first line of the input gives the number of test cases, T. T test cases follow.
    For each test case, the first line contains an integer n(5≤n≤310), the number of the team except LYH’team, the second line contains n distinct integers a(500≤a≤5500), the ith integer represents the penalty of the ith team except his team.
    输出
    For each test case, output one line “Case #x: G S B”, where x is the case number(starting from 1), G is the maximum penalty if he wants to win a gold medal, S is the maximum penalty if he wants to win a silver medal, B is the maximum penalty if he wants to win a bronze medal.
    样例输入
    2
    9
    500 550 600 650 700 750 800 850 900
    10
    500 511 522 533 544 555 566 577 588 599
    样例输出
    Case #1: 499 599 749
    Case #2: 510 543 587
    来源
    原创
    我的代码:
    #include<iostream>
    #include<stdio.h>
    #include<algorithm>
    using namespace std;
    int main()
    {
    int T,i;   
    int ji=1;
    int jin,yin,tong,a1,a2,a3;
    int b[350];
    cin>>T;
    while(T--)
    {
    int n;
    cin>>n;           //总队伍数是n+1
    if((n+1)%10==0)
    jin=(n+1)/10;     //金牌数
    else
    jin=(n+1)/10+1;  //金牌数
    if((n+1)%5==0)
    yin=(n+1)/5;    //银牌数
    else
    yin=(n+1)/5+1;    //银牌数
    if((n+1)*3%10==0)
    tong=(n+1)*3/10;  //铜牌数
    else
    tong=(n+1)*3/10+1; //铜牌数
    for(i=0;i<n;i++)
    {
    cin>>b[i]; //输入除了LYH'team队伍的penalty值
    }
    sort(b,b+n); //从小到大排序
    a1= b[jin-1]-1; //想获得金牌最低也要必须比现在除LYH'team队伍的第一名的penalty少1
    a2=b[jin+yin-1]-1; 
    a3=b[jin+yin+tong-1]-1;
    printf("Case #%d: %d %d %d
    ",ji,a1,a2,a3);
    ji=ji+1;
    }
    return 0;
    }

  • 相关阅读:
    并发容器之CopyOnWriteArrayList
    Python os.listdir() 方法
    Python os.link() 方法
    Python os.lchown() 方法
    Python os.lchmod() 方法
    Python os.lchflags() 方法
    APP test
    jmeter 启动报错:not able to find java executable or version
    sqlserver数据库性能测试方法
    jmeter基础概念
  • 原文地址:https://www.cnblogs.com/NYNU-ACM/p/4236878.html
Copyright © 2020-2023  润新知