PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)
It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.
Each applicant will have to provide two grades: the national entrance exam grade GE, and the interview grade GI. The final grade of an applicant is (. The admission rules are:
The applicants are ranked according to their final grades, and will be admitted one by one from the top of the rank list.
If there is a tied final grade, the applicants will be ranked according to their national entrance exam grade GE. If still tied, their ranks must be the same.
Each applicant may have K choices and the admission will be done according to his/her choices: if according to the rank list, it is one's turn to be admitted; and if the quota of one's most preferred shcool is not exceeded, then one will be admitted to this school, or one's other choices will be considered one by one in order. If one gets rejected by all of preferred schools, then this unfortunate applicant will be rejected.
If there is a tied rank, and if the corresponding applicants are applying to the same school, then that school must admit all the applicants with the same rank, even if its quota will be exceeded.
Input Specification:
Each input file contains one test case.
Each case starts with a line containing three positive integers: N (≤), the total number of applicants; M (≤), the total number of graduate schools; and K (≤), the number of choices an applicant may have.
In the next line, separated by a space, there are M positive integers. The i-th integer is the quota of the i-th graduate school respectively.
Then N lines follow, each contains 2 integers separated by a space. The first 2 integers are the applicant's GE and GI, respectively. The next K integers represent the preferred schools. For the sake of simplicity, we assume that the schools are numbered from 0 to M−1, and the applicants are numbered from 0 to N−1.
Output Specification:
For each test case you should output the admission results for all the graduate schools. The results of each school must occupy a line, which contains the applicants' numbers that school admits. The numbers must be in increasing order and be separated by a space. There must be no extra space at the end of each line. If no applicant is admitted by a school, you must output an empty line correspondingly.
Sample Input:
11 6 3
2 1 2 2 2 3
100 100 0 1 2
60 60 2 3 5
100 90 0 3 4
90 100 1 2 0
90 90 5 1 3
80 90 1 0 2
80 80 0 1 2
80 80 0 1 2
80 70 1 3 2
70 80 1 2 3
100 100 0 2 4
Sample Output:
0 10
3
5 6 7
2 8
1 4
题意:
有n个学生,m个学校,每个人可以填报的志愿为k个,每个人有两个成绩,笔试成绩GE,口试成绩GI,排名按照GE和GI的平均值计算,如果平均值相同,则按照GE排序,如果GE相同,则两学生排名相同
学校的录取规则为:按照成绩排序,再按照每一个 学生填报志愿的顺序,一次向下进行学校判断,如果学校没有收满学生,则录取,如果已经收满学生,但是最后一名收的学生和当前学生排名相同,即使名额超限,也会录取该学生
————————————————
版权声明:本文为CSDN博主「阿_波_」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/li1615882553/article/details/86380237
题解:
结构体排序,模拟即可
AC代码:
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
struct node{
int id;
int rank;
int ge,gi;
vector<int>cho;
}a[];
int num[];
int ran[];
vector<int>sch[];
bool cmp(node x,node y){
if((x.ge+x.gi)==(y.ge+y.gi)){
return x.ge>y.ge;
}else{
return (x.ge+x.gi)>(y.ge+y.gi);
}
}
bool cmp2(int x,int y){
return x<y;
}
int main(){
cin>>n>>m>>k;
memset(ran,,sizeof(ran));
for(int i=;i<m;i++) cin>>num[i];
for(int i=;i<n;i++){
cin>>a[i].ge>>a[i].gi;
a[i].id=i;
for(int j=;j<=k;j++){
int x;
cin>>x;
a[i].cho.push_back(x);
}
}
sort(a,a+n,cmp);
for(int i=;i<n;i++){
if(i==) a[i].rank=;//计算排名
else{
if(a[i].ge==a[i-].ge && a[i].gi==a[i-].gi){
a[i].rank=a[i-].rank;
}else{
a[i].rank=a[i-].rank+;
}
}
for(int j=;j<k;j++){//开始分流志愿
int x=a[i].cho.at(j);
if(num[x]>||ran[x]==a[i].rank){//排名相同也可
sch[x].push_back(a[i].id);
num[x]--;
if(num[x]==) ran[x]=a[i].rank;
break;
}
}
}
for(int i=;i<m;i++){
sort(sch[i].begin(),sch[i].end(),cmp2);//学校内部排序
if(sch[i].size()!=){
for(int j=;j<sch[i].size();j++){
cout<<sch[i].at(j);
if(j!=sch[i].size()-) cout<<" ";
}
}
cout<<endl;
}
return ;
}
PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)的更多相关文章
- pat 甲级 1080. Graduate Admission (30)
		
1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
 - PAT 甲级 1016 Phone Bills (25 分)  (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)
		
1016 Phone Bills (25 分) A long-distance telephone company charges its customers by the following r ...
 - 【PAT甲级】1080 Graduate Admission (30 分)
		
题意: 输入三个正整数N,M,K(N<=40000,M<=100,K<=5)分别表示学生人数,可供报考学校总数,学生可填志愿总数.接着输入一行M个正整数表示从0到M-1每所学校招生人 ...
 - PAT甲级1080 Graduate Admission【模拟】
		
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136 题意: 模拟高考志愿录取. 考生根据总 ...
 - 【PAT甲级】1026 Table Tennis (30 分)(结构体排序,trick较多)
		
题意: 输入一个正整数N(<=10000),表示客户(对)的大小,接着输入N行数据,每行包括一对顾客到场的时间,想要玩的时间,以及是否是VIP客户.接下来输入两个正整数K,M(K<=100 ...
 - PAT 甲级 1030 Travel Plan (30 分)(dijstra,较简单,但要注意是从0到n-1)
		
1030 Travel Plan (30 分) A traveler's map gives the distances between cities along the highways, to ...
 - PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***
		
1049 Counting Ones (30 分) The task is simple: given any positive integer N, you are supposed to co ...
 - PAT 甲级 1026 Table Tennis (30 分)(坑点很多,逻辑较复杂,做了1天)
		
1026 Table Tennis (30 分) A table tennis club has N tables available to the public. The tables are ...
 - PAT 甲级 1072 Gas Station (30 分)(dijstra)
		
1072 Gas Station (30 分) A gas station has to be built at such a location that the minimum distance ...
 
随机推荐
- NFS服务启动:rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
			
nfs重启时提示: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused) 解决办法: 1 #service rpc ...
 - Java调用Kotlin程序深度解析
			
异常: 在之前我们已经学习在Kotlin中的所有异常都是运行期的,而不像Java分为运行期和非运行期,下面用代码来演示一下,先建一个Java的异常: 然后在Kotlin中来调用一下该Java中的方法 ...
 - jmeter脚本中请求参数获取的几种方式
			
a.从数据库获取: 譬如接口请求参数中id的值,我需要从数据库获取,如下设置: 先设置jdbc connection configuration,然后设置JDBC b.从CSV获取: 获取CSV文件 ...
 - hive日期转换函数2
			
转自大神 http://www.oratea.net/?p=944 无论做什么数据,都离不开日期函数的使用. 这里转载一下Hive的日期函数的使用,写的相当完整. 日期函数UNIX时间戳转日期函数: ...
 - LeetCode 983. Minimum Cost For Tickets
			
原题链接在这里:https://leetcode.com/problems/minimum-cost-for-tickets/ 题目: In a country popular for train t ...
 - 10.31-11.1Test(未完)
			
10.31-11.1Test 题目 描述 做法 \(BSOJ5177\) 求在\(n\)个数里选\(K\)个的所有方案的异或和之和 按位讨论,组合数算 \(BSOJ5178\) 化简\(\displa ...
 - idea中properties配置文件 注释显示中文乱码问题
 - 洛谷 P1226 【模板】快速幂||取余运算 题解
			
Analysis 快速幂模板,注意在最后输出时也要取模. 快速幂模板 inline ll ksm(ll x,ll y) { ll ans=; ) { ) { ans*=x; ans%=k; } x*= ...
 - WinDbg常用命令系列---.write_cmd_hist (写命令历史记录)
			
.write_cmd_hist 简介 .write_cmd_hist命令将调试器命令窗口的整个历史记录写入文件. 使用形式 .write_cmd_hist Filename 参数 Filename指定 ...
 - ESP8266低功耗解决的其中一个问题(芯片发热,影响旁边的温湿度芯片)
			
这个项目的这个问题困扰了自己好长时间了,ESP8266芯片发热,导致了旁边的温湿度传感器采集不了空气中的温度....采集的温度是芯片发热的温度 一直采集出来的是30多度......尽管空气温度10几度 ...