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大学生程序设计竞赛

 
  模拟题
  代码:
 #include <iostream>
#include <string.h>
using namespace std;
struct Team{
char s[];
int a,b,c;
}team[];
bool sel[];
void solve(int n,int m,int cnt) //共n个队,输出m个队
{
int i,j,num=;
bool f = false; //是否有女队
for(i=;i<=m;i++){
int Max=,t;
for(j=;j<=n;j++) //找到最大的
if(team[j].b>Max && team[j].b<=num && !sel[j]){
Max = team[j].b;
t = j;
}
num = Max;
if(num<) break;
//找到与这个值相等的最小的值
for(j=;j<=n;j++){
if(team[j].b==num && team[j].c<team[t].c && !sel[j])
t = j;
}
sel[t] = true;
if(team[t].a!=) {f=true;}
}
if(!f){ //如果没有女队
int Max = ,t;
//找到第一个女队
for(i=;i<=n;i++)
if(team[i].a!= && team[i].b>Max && !sel[j]){ //女队
Max = team[i].b;
t = i;
}
//寻找做出这个题数的罚时最少的女队
if(Max!=){
for(i=t;i<=n;i++){
if(team[i].a!= && team[i].b==team[t].b && team[i].c<team[t].c)
t = i;
}
sel[t] = true;
}
}
for(i=;i<=n;i++)
if(sel[i])
cout<<team[i].s<<endl;
}
int main()
{
int N,i,j;
cin>>N;
for(i=;i<=N;i++){
int n,m;
memset(sel,,sizeof(sel));
cin>>n>>m;
for(j=;j<=n;j++) //input
cin>>team[j].s>>team[j].a>>team[j].b>>team[j].c;
//sort(team+1,team+n+1,cmp);
cout<<"Case "<<i<<':'<<endl;
solve(n,m,i);
if(i<N) cout<<endl;
}
return ;
} /**************************************
Problem id : SDUT OJ 2162
User name : Miracle
Result : Accepted
Take Memory : 784K
Take Time : 670MS
Submit Time : 2014-04-20 12:42:48
**************************************/

Freecode : www.cnblogs.com/yym2013

sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)的更多相关文章

  1. sdut 2163:Identifiers(第二届山东省省赛原题,水题)

    Identifiers Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Identifier is an important c ...

  2. sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)

    Crack Mathmen Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Since mathmen take securit ...

  3. sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)

    Ivan comes again! Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...

  4. sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)

    Clockwise Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...

  5. sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)

    Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...

  6. sdut 2154:Shopping(第一届山东省省赛原题,水题)

    Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...

  7. sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)

    Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...

  8. 2016-2017 National Taiwan University World Final Team Selection Contest

    A. Hacker Cups and Balls 二分答案,将$\geq mid$的数看成$1$,$<mid$的数看成$0$,用线段树进行区间排序检查即可.时间复杂度$O(n\log^2n)$. ...

  9. 2016-2017 National Taiwan University World Final Team Selection Contest (Codeforces Gym) 部分题解

      D 考虑每个点被删除时其他点对它的贡献,然后发现要求出距离为1~k的点对有多少个. 树分治+FFT.分治时把所有点放一起做一遍FFT,然后减去把每棵子树单独做FFT求出来的值. 复杂度$nlog^ ...

随机推荐

  1. c++标准库和stl关系

    C++标准库的所有头文件都没有扩展名.C++标准库的内容总共在50个标准头文件中定义,其中18个提供了C库的功能. <cname>形式的标准头文件[ <complex>例外]其 ...

  2. VMWare提供了三种工作模式上网

    VMWare提供了三种工作模式,它们是bridged(桥接模式).NAT(网络地址转换模式)和host-only(主机模式).要想在网络管理和维护中合理应用它们,你就应该先了解一下这三种工作模式. 1 ...

  3. 6种编写HTML和CSS的最有效的方法

    感谢HTML5和CSS3,以及JavaScript,前端开发者有了大大的用武之地.大家都在用很多的工具和技术来武装自己,以加快前段的开发. 本文分享了6中最有效的方法,希望能提供你的效率,为你节约时间 ...

  4. 安装PL/SQL Developer 遇到的问题及解决方法

    在用PL/SQL Developer安装Oracle客户端时,报错误,初始化失败,一直找不到原因,换Oracle版本也解决不了问题,之后才发现,是Oracle的环境变量配置错了,之前用户配了Oracl ...

  5. 15个超实用的php正则表达式

    在这篇文章里,我已经编写了15个超有用的正则表达式,WEB开发人员都应该将它收藏到自己的工具包. 验证域名 检验一个字符串是否是个有效域名. $url = "http://komunitas ...

  6. css 伪类::after ::beftor 的使用方式

    注释:对于 IE8 及更早版本中的 :before,必须声明 . ::before和::after这两个主要用来给元素的前面或后面插入内容,这两个常用"content"配合使用,见 ...

  7. linux远程连接客户端总结

    序:刚从阿里ECS买了一个ubuntu14.04_64_20G,但是没有提供页面登陆工具,因此从网上找了几个远程连接工具,特写在这里算是总结. 1 secureCRT SecureCRT是一款支持SS ...

  8. 繁华模拟赛 Evensgn剪树枝

    #include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...

  9. ThinkPHP 分页实现

    TP3.2框架手册,有一个数据分页,不过每次都要写太多的代码,还有中文设置等有些麻烦,做为程序开发者,有必要整理下: O.先看效果图 一.分页方法 /** * TODO 基础分页的相同代码封装,使前台 ...

  10. storyboard和xib的各种问题

    1.prepareFoSegue注意问题使用该方法设置的值, 必须要 viewWillApear之后用 2.storayboard的使用autolayout, constant = -16, 刚好在f ...