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. DataFrame转矩阵Np-Array

    DataFrame.as_matrix(columns=None)¶ Convert the frame to its Numpy-array representation.

  2. Openresty 与 Tengine

    Openresty 与 Tengine Openresty和Tengine基于 Nginx 的两个衍生版本,某种意义上他们都和淘宝有关系,前者是前淘宝工程师agentzh主导开发的,后者是淘宝的一个开 ...

  3. 为自己的git添加alias,命令缩写

    在多人协作开发时,一般用git来进行代码管理.git有一些命令如:git pull . git push等等,这些命令可以设置alias,也就是缩写.如:git pull 是 git pl, git ...

  4. shell脚本监控Flume输出到HDFS上文件合法性

    在使用flume中发现由于网络.HDFS等其它原因,使得经过Flume收集到HDFS上得日志有一些异常,表现为: 1.有未关闭的文件:以tmp(默认)结尾的文件.加入存到HDFS上得文件应该是gz压缩 ...

  5. POJ 1837 Balance

    Balance Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 9240 Accepted: 5670 Description G ...

  6. 最近打算体验一下discuz,有不错的结构化数据插件

    提交sitemap是每位站长必做的事情,但是提交到哪里,能不能提交又是另外一回事.国内的话百度是大伙都会盯的蛋糕,BD站长工具也会去注册的,可有些账号sitemap模块一直不能用,或许是等级不够,就像 ...

  7. 交叉编译php5,、nginx、squid方法

    本文为原创,转载请注明:http://www.cnblogs.com/tolimit/ 交叉编译php5 软件版本:php-5.4.27 依赖库:zlib,libxml2 交叉编译器:arm-hisi ...

  8. [Effective JavaScript笔记]第3条:当心隐式的强制转换

    js对类型错误出奇的宽容 3+true;  //4 3*””;  //0 3+[]; //3 3+[3]; //33 以上表达式在许多语言早就变红了.而js不但不报错还给你个结果. 极少情况会产生即时 ...

  9. [Effective JavaScript 笔记] 第9条:始终声明局部变量

    如果忘记将变量声明为局部变量,该变量将会隐式地转变为全局变量 function swap(a,i,j){ temp=a[i]; a[i]=a[j]; a[j]=temp; } 尽管该程序没有使用var ...

  10. ruby代码重构第二课

    (文章都是从我的个人主页上粘贴过来的, 大家也可以访问我的主页 www.iwangzheng.com) 在第一课里提取出了相通的代码,第二课里就把常量提取出来吧 一般把常量的定义写的对应的app/mo ...