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 ...
随机推荐
- MAC mysql安装及设置
MAC下安装MYSQL有两种方式,一种为压缩包形式 另一种为.dmg文件安装包 . 首先先介绍压缩包形式的安装方法: 去MySql官网下MySQL classic版mysql-5.1.54-osx ...
- CF Pangram
Pangram time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- 关于Linux系统和Windows系统中文件夹的命名规范
Windows系统中. 1.在创建文件夹的时候不能以"."开头(但是文件以多个点开头并且还有其他合法字符的话就是合法的) 但是在windows系统中确实见过以一个点".& ...
- Sqlite官方下载对应版本注意细节
官网下载地址: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki 下载注意事项: 1.对应.net平台 2.对 ...
- 详解HTML<head> 头标签元素的意义以及使用场景
HTML<head>头部分的标签.元素有很多,涉及到浏览器对网页的渲染,SEO 等等,而各个浏览器内核以及各个国内浏览器厂商都有些自己的标签元素,这就造成了很多差异性.移动互联网时代,he ...
- No Dialect mapping for JDBC type: -1
MySQL数据库中有张表的字段是text,查询出来后对应的java类型是String,Dialect设置为org.hibernate.dialect.MySQLDialect 运行的时候报错:No D ...
- Jersey(1.19.1) - Client API, Proxy Configuration
为 Jersey Client 设置代理,可以使用带有 ClientHandler 参数的构造方法创建 Client 实例. public static void main(String[] args ...
- jquery之css()改变字体大小,颜色,背景色
转: <script type="text/javascript"> $(document).ready(function() { $("#f ...
- C#——字符操作
题目要求:用户随机输入字母及数字组成的字符串,当用户连续输入字符串‘hello’时,程序结束用户输入,并分别显示用户输入的字母及数字的数目. 代码: using System; using Syste ...
- asp.net导出Excel
注意这种方法,导出的excel没有网格线 当在导出Execl或Word的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误提示.下面的2 ...