1080. Graduate Admission (30)
It is said that in 2013, there were 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 (GE + GI) / 2. 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 (<=40,000), the total number of applicants; M (<=100), the total number of graduate schools; and K (<=5), 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+K 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
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std; struct stu
{
int Gin;
int id;
double GAvg;
int rank;
vector<int> app;
}; vector< stu > Student;
vector<int> School[];
bool isfull[]; int cmp2(int a,int b )
{
return a < b;
} int cmp(stu a,stu b)
{
if(a.GAvg != b.GAvg) return a.GAvg > b.GAvg;
return a.Gin > b.Gin;
} int main()
{
int stunum,schoolnum,appcnum;
vector<int> admit;
scanf("%d%d%d",&stunum,&schoolnum,&appcnum);
int i;
for(i = ; i < schoolnum ; i++ )
{
int tem ;
scanf("%d",&tem);
admit.push_back(tem);
} for(i = ; i < stunum ; i++)
{
int temGin,temGfu;
scanf("%d%d",&temGin,&temGfu);
stu temstu;
temstu.id = i;
temstu.Gin = temGin;
temstu.GAvg = (double)(temGin + temGfu)*1.0/;
for(int j= ; j < appcnum ; j++)
{
int apptem;
scanf("%d",&apptem);
temstu.app.push_back(apptem);
} Student.push_back(temstu);
} sort(Student.begin(),Student.end(),cmp); Student[].rank = ; for(i = ; i < stunum ; i++)
{
if(Student[i-].GAvg == Student[i].GAvg && Student[i].Gin == Student[i-].Gin)
{
Student[i].rank = Student[i - ].rank;
}
else
{
Student[i].rank = i + ;
}
} for(i = ; i < stunum ; i ++)
{
int index = Student[i].rank;
vector<stu> StudentTem;
int j;
while( i < stunum )
{
if(Student[i].rank == index)
StudentTem.push_back(Student[i]);
else
{
break;
}
i ++;
}
--i; for(j = ; j < StudentTem.size() ; j ++)
{
for(int k = ; k < StudentTem[j].app.size() ; k ++)
{
if(!isfull[StudentTem[j].app[k]])
{
School[ StudentTem[j].app[k] ].push_back(StudentTem[j].id);
break;
}
}
} for(j = ; j < schoolnum ; j ++)
{
if(School[j].size() >= admit[j] )
isfull[j] = ;
}
} for(i = ; i < schoolnum ; i++)
{
bool fir = ;
sort(School[i].begin(),School[i].end(),cmp2);
for(int j = ; j < School[i].size() ; j ++)
{
if(fir)
{
printf("%d",School[i][j]);
fir = ;
}
else
{
printf(" %d",School[i][j]);
}
}
printf("\n");
} return ; }
1080. Graduate Admission (30)的更多相关文章
- pat 甲级 1080. Graduate Admission (30)
1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)
1080 Graduate Admission (30 分) It is said that in 2011, there are about 100 graduate schools ready ...
- PAT 1080. Graduate Admission (30)
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...
- 1080 Graduate Admission (30)(30 分)
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...
- PAT (Advanced Level) 1080. Graduate Admission (30)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- 1080. Graduate Admission (30)-排序
先对学生们进行排序,并且求出对应排名. 对于每一个学生,按照志愿的顺序: 1.如果学校名额没满,那么便被该学校录取,并且另vis[s][app[i].ranks]=1,表示学校s录取了该排名位置的学生 ...
- 【PAT甲级】1080 Graduate Admission (30 分)
题意: 输入三个正整数N,M,K(N<=40000,M<=100,K<=5)分别表示学生人数,可供报考学校总数,学生可填志愿总数.接着输入一行M个正整数表示从0到M-1每所学校招生人 ...
- pat1080. Graduate Admission (30)
1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- PAT 1080 Graduate Admission[排序][难]
1080 Graduate Admission(30 分) It is said that in 2011, there are about 100 graduate schools ready to ...
随机推荐
- Storm中并发程度的理解
Storm中涉及到了很多组件,例如nimbus,supervisor等等,在参考了这两篇文章之后,对这个有了更好的理解. Understanding the parallelism of a Stor ...
- Node.js module.exports和exports的区别
require 用来加载代码,而 exports 和 module.exports 则用来导出代码,从接触node.js就不会它们两陌生,上代码: foo.js exports.a = functio ...
- javaweb学习总结二十一(servlet开发入门、servlet生命周期以及调用过程)
一:servlet开发入门 servlet是sun公司一门开发动态web资源的技术,下面编写一个servlet入门程序: 1:在tomcat服务器webapps目录下新建firstServlet目录, ...
- Linux 源码安装apache 与常见错误解决
文档原位置 一.编译安装apache 1.解决依赖关系 httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级. 升级方式有两种,一种是通过源代码编译安装,一种是直接升 ...
- [书目20131114]微软技术丛书•快速软件开发(珍藏版) Rapid Development Taming Wild Software Schedules By Steve McConnell
本文摘自:http://shop.oreilly.com/product/9781556159008.do EFFICIENT DEVELOPMENT Chapter 1 Welcome to Rap ...
- 关于Linux系统和Windows系统中文件夹的命名规范
Windows系统中. 1.在创建文件夹的时候不能以"."开头(但是文件以多个点开头并且还有其他合法字符的话就是合法的) 但是在windows系统中确实见过以一个点".& ...
- hdu 3635 Dragon Balls
Dragon Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- Features for configuring JSON-to-Java mapping
Following on/off features are defined in DeserializationConfig.Feature (Jackson 1.x) or Deserializat ...
- JMS - 消息确认
消息确认机制 消息确认协议是保证消息传送的关键所在,同时,支持确认也是 JMS API 语义的要求.以下将分别从消息生产者.消息服务器.消息消费者的角度,来考察消息确认机制. 从消息生产者的角度考察 ...
- django 学习-5 模板使用流程
首先在模板下建一个index.html <!DOCTYPE html><html><head><meta charset="utf-8" ...