SDUT 2162-The Android University ACM Team Selection Contest(模拟)
来源:互联网 发布:淘宝店铺被违规警告 编辑:程序博客网 时间:2024/06/05 05:53
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.
输出
示例输入
35 3AU001 0 0 0AU002 1 1 200AU003 1 1 30AU004 0 5 500AU005 0 7 10002 1BOYS 0 10 1200GIRLS 10 1 2903 3red 0 0 0green 0 0 0blue 0 1 30
示例输出
Case 1:AU003AU004AU005Case 2:BOYSGIRLSCase 3:blue33
提示
来源
题意:模拟ACM比赛排名,
在一些队伍中选择几个队伍获奖。接下来是队伍获奖产生的规则:
①只有做出题目的队伍,才能获奖。
②如果选出获奖的队伍中没有女生队伍,那么要将所有女队中排名第一的也要给奖。
③获奖排名,按照输入时的顺序输出队名。
④如果获奖队伍不够,先输出获奖的队伍,剩下的空缺用,奖项数量来代替输出。
例如最后一个样例:只有blue获奖,但是要选出3个队伍,所以剩下两个空缺,用3来代替输出。
⑤是否是女队。
#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const double pi= acos(-1.0);struct node{ char name[30]; int a,t,p;//依次是是否有女队,出题数,罚时 int flag; int id;//记录序号}q[10010];int cmp1(struct node x,struct node y){ if(x.t!=y.t) return x.t>y.t; else return x.p<y.p;}int cmp2(struct node x,struct node y){ return x.id<y.id;}int main(){ int T; int icase; int n,m,i,j; scanf("%d",&T); for(icase=1;icase<=T;icase++){ scanf("%d %d",&n,&m); for(i=0;i<n;i++){ scanf("%s %d %d %d",&q[i].name,&q[i].a,&q[i].t,&q[i].p); q[i].id=i; q[i].flag=0; } std:: sort(q,q+n,cmp1); int f=0; for(i=0;i<m;i++){ if(q[i].t>0){ q[i].flag=1; if(q[i].a!=0) f=1; } } if(f==0){ for(i=m;i<n;i++){ if(q[i].t>0&&q[i].a!=0){ q[i].flag=1; break; } } } std::sort(q,q+n,cmp2); printf("Case %d:\n",icase); for(i=0;i<n;i++){ if(q[i].flag) printf("%s\n",q[i].name); } if(icase<T) puts(""); } return 0;}
- SDUT 2162-The Android University ACM Team Selection Contest(模拟)
- The Android University ACM Team Selection Contest
- 山东省第二届ACM大学生程序设计竞赛 The Android University ACM Team Selection Contest
- 山东省第二届ACM省赛题——The Android University ACM Team Selection Contest
- 山东省第二届ACM大学生程序设计竞赛:The Android University ACM Team Selection Contest
- 山东省第二届ACM省赛 The Android University ACM Team Selection Contest
- [2011山东省第二届ACM大学生程序设计竞赛]——The Android University ACM Team Selection Contest
- Sdut 2409 The Best Seat in ACM Contest(山东省第三届ACM省赛 H 题)(模拟)
- poj 3138 ACM Team Selection
- Summer Training Team Selection (1) Problem A ACM Contest Scoring 水题
- SDUT 2409:The Best Seat in ACM Contest
- 【ZOJ3956 The 17th Zhejiang University Programming Contest I】【01背包】Course Selection System 公式最大化
- POJ 3138 ACM Team Selection 笔记
- 【2014 Multi-University Training Contest 6】 J. Fighting the Landlords(模拟)
- HDU 5373 The shortest problem(模拟)——2015 Multi-University Training Contest 7
- 2016 UESTC ACM Summer Training Team Selection (2)解题报告
- sdut 2624 Contest Print Server (模拟)
- [2012山东ACM省赛] The Best Seat in ACM Contest (模拟)
- 声明一个Circle类,有数据成员radius(半径),成员函数area(),计算圆的面积,构造一个Circle的对象进行测试
- C++中的联合和case?
- 希尔排序
- 进制转换
- Mac OS X 下捕获App局域网通讯包
- SDUT 2162-The Android University ACM Team Selection Contest(模拟)
- 开闭原则(open-close principle)
- 第四周项目一三角形类的构造函数-1
- mac中quick-cocos2dx-2.2.5+sublime text 2搭建lua的开发环境
- Android 动态添加View
- UVa 1623 - Enter The Dragon(贪心)
- HDU Proud Merchants 最优解+背包
- 经验总结:WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法
- 移动端 去除滚动条