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^ ...
随机推荐
- Sphinx学习之sphinx的安装篇
一. Sphinx简介 Sphinx是由俄罗斯人Andrew Aksyonoff开发的一个全文检索引擎.意图为其他应用提供高速.低空间占用.高结果 相关度的全文搜索功能.Sphinx可以非常容易的与 ...
- 修复UIImagePickerController偷换StatusBar颜色的问题
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:( ...
- 自定义NSLog无时间
#define SXLog(FORMAT, ...) fprintf(stderr,"file --\t%s\nline --\t%d\nmethd --\t%s\noutput --\t\ ...
- tcp 重发 应用层重传
采用TCP时,应用层需要超时重传吗? 需要,原因如下: 1 tcp的超时控制不是你能设置的,所有的tcp超时都是用系统的时间设定,而且这个时间很长,超时的结果就是断开连接.和你应用要达到的目的显然差很 ...
- SVN服务器搭建--Subversio与TortoiseSVN的配置安装
SVN服务器搭建和使用(一) Subversion是优秀的版本控制工具,其具体的的优点和详细介绍,这里就不再多说. 首先来下载和搭建SVN服务器. 现在Subversion已经迁移到apache网站上 ...
- Android之开启手机系统自带铃声
/** * 开启手机系统自带铃声 */ private void startAlarm() { mMediaPlayer = MediaPlayer.create(this, getSystemDef ...
- Insertion Sort List
对链表进行插入排序,比对数组排序麻烦一点. ListNode *insertSortList(ListNode *head) { ListNode dummy(-); for (ListNode *c ...
- Vmware怎样使用nat和桥接方式解决虚拟机联网问题
对于很多的linux初学者来说,最开始学习linux时通常是在虚拟机上进行的,然而对于新手来说虚拟机联网会对他们来说是比较困难的.这里我根据自己的经验写了一篇文档分享给大家.下面对几种连接方式进行简单 ...
- 【Python】python list 迭代删除
最好方式使用filter,代码示例: def _filter(self, item): ): return False return True #lambda e:e%!= data['items'] ...
- java中四种阶乘的计算
package com.zf.s2;//创建一个包 import java.math.BigInteger;//导入类 import java.util.ArrayList; import jav ...