zoukankan      html  css  js  c++  java
  • sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)

    The Android University ACM Team Selection Contest

    Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

    题目描述

     Now it's 20000 A.D., and the androids also participate in the ACM Inter-national Collegiate Programming Contest (ACM/ICPC). In order to select the members of Android University ACM/ICPC Training Camp, a contest was held. There were N teams competing in the contest, among which there might be some teams whose members are all girls (they are called all-girls teams). Some of the N teams will be selected, then all the members of those teams are selected as the members of the training camp.

    To be selected, one team has to solve at least one problem in the contest. The the top M teams who solved at least one problem are selected (If there are less than M teams solving at least one problem, they are all selected).

    There is an bonus for the girls - if top M teams contains no all-girls teams,the highest ranked all-girls team is also selected (together with the M top teams), provided that they have solved at least one problem.

    Recall that in an ACM/ICPC style contest, teams are ranked as following:

    1. The more problems a team solves, the higher order it has.

    2. If multiple teams have the same number of solved problems, a team with a smaller penalty value has a higher order than a team with a

    larger penalty value.

    Given the number of teams N, the number M defined above, and each team's name, number of solved problems, penalty value and whether it's an all-girls team, you are required to write a program to find out which teams are selected.

    输入

     The input has multiple test cases. The first line of the input contains one integer C, which is the number of test cases.

    Each test case begins with a line contains two integers, N (1 <= N <=10^4) and M (1 <= M <= N), separated by a single space. Next will be N lines, each of which gives the information about one specific competing team.Each of the N lines contains a string S (with length at most 30, and consists of upper and lower case alphabetic characters) followed by three integers, A(0 <= A <= 10), T (0 <= T <= 10) and P (0 <= P <= 5000), where S is the name of the team, A indicates whether the team is an all-girls team (it is not an all-girls team if Ai is 0, otherwise it is an all-girls team). T is the number of problems the team solved, and P is the penalty value of the team.

    The input guarantees that no two teams who solved at least one problem have both the same T and P.

    输出

     For each test case, print one line containing the case number (starting from 1). Then, output the selected teams' names by the order they appear in the input, one on each line. Print a blank line between the output for two test cases. Refer to the Sample Output section for details.

    示例输入

    3
    5 3
    AU001 0 0 0
    AU002 1 1 200
    AU003 1 1 30
    AU004 0 5 500
    AU005 0 7 1000
    2 1
    BOYS 0 10 1200
    GIRLS 10 1 290
    3 3
    red 0 0 0
    green 0 0 0
    blue 0 1 30

    示例输出

    Case 1:
    AU003
    AU004
    AU005
    Case 2:
    BOYS
    GIRLS
    Case 3:
    blue
    3
    3

    提示

     

    来源

    山东省第二届ACM大学生程序设计竞赛
     
      模拟题
      代码:
     1 #include <iostream>
     2 #include <string.h>
     3 using namespace std;
     4 struct Team{
     5     char s[31];
     6     int a,b,c;
     7 }team[10001];
     8 bool sel[10001];
     9 void solve(int n,int m,int cnt) //共n个队,输出m个队
    10 {
    11     int i,j,num=999999999;
    12     bool f = false; //是否有女队
    13     for(i=1;i<=m;i++){
    14         int Max=0,t;
    15         for(j=1;j<=n;j++)   //找到最大的
    16             if(team[j].b>Max && team[j].b<=num && !sel[j]){
    17                 Max = team[j].b;
    18                 t = j;
    19             }
    20         num = Max;
    21         if(num<1) break;
    22         //找到与这个值相等的最小的值
    23         for(j=1;j<=n;j++){
    24             if(team[j].b==num && team[j].c<team[t].c && !sel[j])
    25                 t = j;
    26         }
    27         sel[t] = true;
    28         if(team[t].a!=0) {f=true;}
    29     }
    30     if(!f){ //如果没有女队
    31         int Max = 0,t;
    32         //找到第一个女队
    33         for(i=1;i<=n;i++)
    34             if(team[i].a!=0 && team[i].b>Max && !sel[j]){    //女队
    35                 Max = team[i].b;
    36                 t = i;
    37             }
    38         //寻找做出这个题数的罚时最少的女队
    39         if(Max!=0){
    40             for(i=t;i<=n;i++){
    41                 if(team[i].a!=0 && team[i].b==team[t].b && team[i].c<team[t].c)
    42                     t = i;
    43             }
    44             sel[t] = true;
    45         }
    46     }
    47     for(i=1;i<=n;i++)
    48         if(sel[i])
    49             cout<<team[i].s<<endl;
    50 }
    51 int main()
    52 {
    53     int N,i,j;
    54     cin>>N;
    55     for(i=1;i<=N;i++){
    56         int n,m;
    57         memset(sel,0,sizeof(sel));
    58         cin>>n>>m;
    59         for(j=1;j<=n;j++)   //input
    60             cin>>team[j].s>>team[j].a>>team[j].b>>team[j].c;
    61         //sort(team+1,team+n+1,cmp);
    62         cout<<"Case "<<i<<':'<<endl;
    63         solve(n,m,i);
    64         if(i<N) cout<<endl;
    65     }
    66     return 0;
    67 }
    68 
    69 /**************************************
    70     Problem id    : SDUT OJ 2162 
    71     User name    : Miracle 
    72     Result        : Accepted 
    73     Take Memory    : 784K 
    74     Take Time    : 670MS 
    75     Submit Time    : 2014-04-20 12:42:48  
    76 **************************************/

    Freecode : www.cnblogs.com/yym2013

  • 相关阅读:
    【SpringBoot】 理解SpringBoot的启动原理
    【SpringBoot】SpringBoot的基础,全面理解bean的生命周期
    【转】 Linux 命令解释(Linux基础二)
    【转】 Linux 的目录详解 (Linux基础一)
    【SpringBoot】 一种解决接口返回慢的方式
    【Jmeter基础】 Linux上运行Jmeter
    【SpingBoot】 测试如何使用SpringBoot搭建一个简单后台1
    单例模式@Singleton在测试中的运用
    性能测试基础 ---TCP通信过程的状态码与过程,以及出现错误码的分析(TIME_WAIT,CLOSE_WAIT)
    Spring5源码分析(007)——IoC篇之加载BeanDefinition总览
  • 原文地址:https://www.cnblogs.com/yym2013/p/3678998.html
Copyright © 2011-2022 走看看