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 ...
随机推荐
- java.lang.IllegalStateException
java.lang.IllegalStateExceptionorg.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFac ...
- iOS 获取内存大小使用情况(进度条显示)
一.获取设备内存大小方法 //返回存储内存占用比例 - (NSString *)getFreeDiskspaceRate{ float totalSpace; .f; NSError *error = ...
- 转:Nginx RTMP 功能研究
看点: 1. Nginx 配置信息与使用. (支持 rtmp与HLS配置) 2. 有ffmpeg 编译与使用, 命令行方式来测试验证客户端使用. 转自:http://blog.cs ...
- 转:android 设计模式合集
转: http://mobile.51cto.com/android-419145.htm
- 10秒视频转局部GIF动画
10秒视频转局部GIF动画,微软出品的一款精致小软件. 百度云盘:http://pan.baidu.com/s/1i3SARfn
- 也谈Asp.net 中的身份验证
钱李峰 的这篇博文<Asp.net中的认证与授权>已对Asp.net 中的身份验证进行了不错实践.而我这篇博文,是从初学者的角度补充了一些基础的概念,以便能有个清晰的认识. 一.配置安全身 ...
- HDU(搜索专题) 1000 N皇后问题(深度优先搜索DFS)解题报告
前几天一直在忙一些事情,所以一直没来得及开始这个搜索专题的训练,今天做了下这个专题的第一题,皇后问题在我没有开始接受Axie的算法低强度训练前,就早有耳闻了,但一直不知道是什么类型的题目,今天一看,原 ...
- 老男孩-金角大王-python学习博客地址
http://www.cnblogs.com/alex3714/category/770733.html
- php递归方法实现无限分类实例
数组: 代码如下 复制代码 $items = array( array('id' => 1, 'pid' => 0, 'name' => '一级11' ), array('id' ...
- Cocos2d-x开发实例:单点触摸事件
下面我们通过一个实例详细了解一下,层中单点触摸事件的实现过程.感受一下它的缺点和优点.该实例场景如下图所示,场景中有两个方块精灵,我们可以点击和移动它们. 下面我们看看HelloWorldScen ...