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^ ...
随机推荐
- Extreme Learning Machine(ELM)的工程哲学
Extreme Learning Machine(ELM)的工程哲学 David_Wang2015 发布于2015年5月6日 11:29 工程问题往往需要的是一定精度范围内的结果,而不是“真正的”结果 ...
- 一种透明效果的view
设置这个view背景色: [UIColor colorWithRed: green: blue: alpha:0.3]; 效果如下:
- zabbix 分布式监控(proxy)源码安装
安装分布式监控(代理节点) 1.下载软件zabbix-3.2.1.tar.gz 1.1 解压 wget http://nchc.dl.sourceforge.net/project/zabbix/ZA ...
- ios开发 <AppName>-Prefix.pch文件的用法详解
我们知道,每新建立一个工程,比如说HelloWord,在分类SupportingFiles里都会有一个以工程名开头-Prefix.pch结尾的文件,如HelloWord-Prefix.pch.对于这个 ...
- 繁华模拟赛 Evensgn剪树枝
#include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...
- 微信5.4你所不知道的事 X5浏览引擎提速50%-80%
微信5.4新增包括搜索公众号.识别图中二维码.面对面收钱等功能,但是你可知道新版微信X5浏览引擎提速了,提升50%-80%的网络传输速度及相同比例流量节省? 从X5浏览引擎开发人员得知,X5浏览技术基 ...
- Hadoop日记Day1---Hadoop介绍
一.Hadoop项目简介 1. Hadoop是什么 Hadoop是一个适合大数据的分布式存储与计算平台. 作者:Doug Cutting:Lucene,Nutch. 受Google三篇论文的启发 2. ...
- Android Toast 封装,避免Toast消息覆盖,替换系统Toast最好用的封装
Android Toast 封装,避免Toast消息覆盖,无阻塞,等强大功能 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ...
- characterCustomezition的资源打包代码分析
using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; class Creat ...
- 用poi框架进行批量导入导出实例
Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程式对Microsoft Office格式档案读和写的功能.我们这里使用poi对数据库中的数据进行批量导出,以及 ...