sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)
The Android University ACM Team Selection Contest
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
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.
输入
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.
输出
示例输入
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
提示
来源
#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(第二届山东省省赛原题,模拟题)的更多相关文章
- sdut 2163:Identifiers(第二届山东省省赛原题,水题)
Identifiers Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Identifier is an important c ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)
Ivan comes again! Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...
- sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)
Clockwise Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...
- sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)
Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...
- sdut 2154:Shopping(第一届山东省省赛原题,水题)
Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...
- sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)
Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...
- 2016-2017 National Taiwan University World Final Team Selection Contest
A. Hacker Cups and Balls 二分答案,将$\geq mid$的数看成$1$,$<mid$的数看成$0$,用线段树进行区间排序检查即可.时间复杂度$O(n\log^2n)$. ...
- 2016-2017 National Taiwan University World Final Team Selection Contest (Codeforces Gym) 部分题解
D 考虑每个点被删除时其他点对它的贡献,然后发现要求出距离为1~k的点对有多少个. 树分治+FFT.分治时把所有点放一起做一遍FFT,然后减去把每棵子树单独做FFT求出来的值. 复杂度$nlog^ ...
随机推荐
- SSH整合之spring整合hibernate
SSH整合要导入的jar包: MySQL中创建数据库 create database ssh_db; ssh_db 一.spring整合hibernate带有配置文件hibernate.cfg.xml ...
- Java初学(二)
一.数据类型 在定义Long或者Float类型变量的时候,要加L或f(大小写无关,只是便于识别,建议不要小写L) 整数默认是int,浮点数默认是double 二.java字符 java语言采用的是Un ...
- DataTable列上多值运算
1.从网上找了个中缀算法(也不知道什么前缀后缀,抱歉),可以对字符串表达式进行运算 2.有些时候还是会用到ASCII码表的 char c = expression[k];//expression为一字 ...
- Linux下tomcat作为守护进程运行(开机启动、以指定的用户运行、解决非root身份不能绑定1024以下端口的问题)的配置方法
如题. 参考资料: http://www.jdiy.org/read.jd?id=y0haaynq1w http://blog.csdn.net/shw2004/article/details/578 ...
- 斯坦福大学CS224d基础1:线性代数回顾
转自 http://blog.csdn.net/han_xiaoyang/article/details/51629242 斯坦福大学CS224d基础1:线性代数知识 作者:Zico Kolter ( ...
- js通过alert查看对象或数组内容
var arr=new Array("Saab","Volvo","BMW"); for(i in arr ){ alert(i); //获 ...
- 防止ajax请求重发
debounce ajax请求,防止用户点击过快造成重发 按钮disabled处理,显示loading,防止用户失去耐心,重复点击 表单提交也可以同样处理.
- 使用ymPrompt弹框
使用弹框 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8&q ...
- 最诡异的Linux fork进程问题(我们平时都在写)
从来没有遇到过... 运行环境:在Linux自带的文本编辑器中输入C程序,在shell中编译运行,下面直接看代码和运行结果. 第一个代码:#include<stdio.h> #includ ...
- (转)也谈基于NodeJS的全栈式开发(基于NodeJS的前后端分离)
原文链接:http://ued.taobao.org/blog/2014/04/full-stack-development-with-nodejs/ 随着不同终端(pad/mobile/pc)的兴起 ...