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 G​E​​, and the interview grade G​I​​. 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 G​E​​. 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 G​E​​ and G​I​​, 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
 #include <iostream>
#include <vector>
#include <algorithm>
//录取规则,排名靠前的人优先选择学校
using namespace std;
int N, M, K;
struct Node
{
int id, Ge, Gt, G, rank, choice[];
}node;
struct Sch
{
int quto;
vector<pair<int,int>>admin;//录取的学生id,rank
}sch;
vector<Sch>school;
vector<Node>applicant;
bool cmp(Node a, Node b)
{
if (a.G != b.G)
return a.G > b.G;
else
return a.Ge > b.Ge;
}
int main()
{
cin >> N >> M >> K;
for (int i = ; i < M; ++i)
{
cin >> sch.quto;
school.push_back(sch);
}
for (int i = ; i < N; ++i)
{
cin >> node.Ge >> node.Gt;
node.G = node.Ge + node.Gt;
node.id = i;
for (int j = ; j < K; ++j)
{
int t;
cin >> t;
node.choice[j] = t;//志愿学校
}
applicant.push_back(node);
}
sort(applicant.begin(), applicant.end(), cmp);
applicant[].rank = ;
for (int i = ; i < N; ++i)//排名
{
if (applicant[i].G == applicant[i - ].G && applicant[i].Ge == applicant[i - ].Ge)
applicant[i].rank = applicant[i - ].rank;
else
applicant[i].rank = i + ;
}
for (int i = ; i < N; ++i)//按学生选学校
{
for (int j = ; j < K; ++j)
{
int t = applicant[i].choice[j];
if (school[t].quto == && (school[t].admin.end() - )->second == applicant[i].rank)//排名相同可以超额
{
school[t].admin.push_back(make_pair(applicant[i].id, applicant[i].rank));//超额录取
break;
}
else if (school[t].quto == )
continue;//面试下一所学校,该学校满额
else
{
school[t].admin.push_back(make_pair(applicant[i].id, applicant[i].rank));//正常录取
school[t].quto--;//名额减少
break;
}
}
}
for (int i = ; i < M; ++i)
{
sort(school[i].admin.begin(), school[i].admin.end());
for (int j = ; j < school[i].admin.size(); ++j)
cout << school[i].admin[j].first << (j == school[i].admin.size() - ? "" : " ");
cout << endl;
}
return ;
}

PAT甲级——A1080 Graduate Admission的更多相关文章

  1. pat 甲级 1080. Graduate Admission (30)

    1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...

  2. PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)

    1080 Graduate Admission (30 分)   It is said that in 2011, there are about 100 graduate schools ready ...

  3. PAT甲级1080 Graduate Admission【模拟】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136 题意: 模拟高考志愿录取. 考生根据总 ...

  4. A1080. Graduate Admission

    It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...

  5. PAT_A1080#Graduate Admission

    Source: PAT A1080 Graduate Admission (30 分) Description: It is said that in 2011, there are about 10 ...

  6. 1080 Graduate Admission——PAT甲级真题

    1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were about 100 graduate schools rea ...

  7. PAT 1080 Graduate Admission[排序][难]

    1080 Graduate Admission(30 分) It is said that in 2011, there are about 100 graduate schools ready to ...

  8. PAT甲级题解(慢慢刷中)

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  9. 【转载】【PAT】PAT甲级题型分类整理

    最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...

随机推荐

  1. QTP,自己主动化測试学习笔记,六月九号

    測试自己主动化实现的两个难点设计--功能分解 实现--对象的识别 測试自己主动化实现的两个难点-功能分解 清晰画出业务流程图 依据业务流程分解业务功能.能够被复用的功能也要被分解出来. 依照路径覆盖的 ...

  2. linux下创建oracle表空间

    来自:http://blog.sina.com.cn/s/blog_62192aed01018aep.html 1 . 登录服务器 2 . 查看磁盘空间是否够大df -h -h更具目前磁盘空间和使用情 ...

  3. 21-4indexOf

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. Producer-Consumer 生产者,消费者

    这个模式跟Guarded模式有点类似,不过需要一个控制台限制请求方和处理方的频度和数量. public class ProducerConsumerTest { /** * @param args * ...

  5. PyQt6的在线安装与环境配置

    https://www.jianshu.com/p/185e277e0058 一,安装好Python,Pycharm 二,安装或更新pip C:\> python -m pip install ...

  6. JQUERY(入口函数 选择器)

    入口函数   $(document).ready(function(){ });可以简写为$(function(){}) 选择器 基本选择器 元素选择器   $("p") 所有 & ...

  7. 期望dp+高斯消元优化——uvalive4297好题

    非常好的题!期望+建矩阵是简单的,但是直接套高斯消元会T 所以消元时要按照矩阵的形态 进行优化 #include<bits/stdc++.h> using namespace std; ; ...

  8. 实用的 atom 插件

    推荐几款我喜欢的Atom插件 时间 2017-05-05 09:00:00  Hi Linux 原文  http://www.hi-linux.com/posts/28459.html 主题 Atom ...

  9. 图解 5 种 Join 连接及实战案例!(inner/ left/ right/ full/ cross)

    Join 连接在日常开发用得比较多,但大家都搞清楚了它们的使用区别吗??一文带你上车~~ 内连接 inner join 内连接是基于连接谓词将俩张表(如A和B)的列组合到一起产生新的结果表,在表中存在 ...

  10. 干货:排名前 16 的 Java 工具类!

    在Java中,工具类定义了一组公共方法,这篇文章将介绍Java中使用最频繁及最通用的Java工具类.以下工具类.方法按使用流行度排名,参考数据来源于Github上随机选取的5万个开源项目源码. 一. ...