时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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)的更多相关文章

  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 (30)

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

  4. 1080 Graduate Admission (30)(30 分)

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

  5. PAT (Advanced Level) 1080. Graduate Admission (30)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  6. 1080. Graduate Admission (30)-排序

    先对学生们进行排序,并且求出对应排名. 对于每一个学生,按照志愿的顺序: 1.如果学校名额没满,那么便被该学校录取,并且另vis[s][app[i].ranks]=1,表示学校s录取了该排名位置的学生 ...

  7. 【PAT甲级】1080 Graduate Admission (30 分)

    题意: 输入三个正整数N,M,K(N<=40000,M<=100,K<=5)分别表示学生人数,可供报考学校总数,学生可填志愿总数.接着输入一行M个正整数表示从0到M-1每所学校招生人 ...

  8. pat1080. Graduate Admission (30)

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

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

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

随机推荐

  1. 引用自定义的framework

    关于静态库引用文件 如果希望你的工程能在未来能导出成静态库,那么在你编写的时候要遵循静态库引用原则,使用这种方式. 注意:这种引用方式必须在你的Products下静态库成黑色时候,才能编译通过. 使用 ...

  2. 【Nginx 1】Nginx 的下载和安装

    今天正式开始学习Nginx.Nginx是一个著名的轻量级Http服务器,目前已经有很多知名网站使用Nginx作为服务器.因为Nginx是开源的软件,因此对于开发人员和学习者来说都是一个大宝藏. 首先, ...

  3. angularjs $state.go 传参

    在目标页面规定接受的参数:$stateProvider.state('page2', {params: {'data': null}}) 传参:$state.go('page2', {data: 'a ...

  4. mysql 修改 character_set_database 编码格式

    操作系统:win10  x64 Server version : 5.5.46 MySQL Community Server (GPL) mysql 修改 character_set_database ...

  5. sqlserver2005数据库18456错误(转)

    第一步.以windows验证模式进入数据库管理器.第二步:右击sa,选择属性:在常规选项卡中,重新填写密码和确认密码(改成个好记的).把强制实施密码策略去掉.第三步:点击状态选项卡:勾选授予和启用.然 ...

  6. Java Concurrency - 取消线程执行器中的线程

    When you work with an executor, you don't have to manage threads. You only implement the Runnable or ...

  7. CentOS安装Node.js简单教程

    记录一下自己安装过程 先安装gcc-c++编译环境和openssl  代码如下 复制代码 yum install gcc-c++ openssl-devel wget http://nodejs.or ...

  8. mysql定时脚本(event),类似oracle的job

    mysql定时脚本(event),类似oracle的job   我有2张表:tb_push_data 和 tb_push_data_log 现在需要每隔一段时间将tb_push_data 符合条件的 ...

  9. Oracle 硬解析查询

    -- 硬解析的 parse count (hard) select * from v$sysstat where name like '%parse%'; select a.value,b.name ...

  10. Swift静态方法

    与静态属性类似,Swift中还定义了静态方法,也称为类型方法,所谓“类型”是指枚举.结构体和类.静态方法定义的方法也是与静态属性类似的,枚举和结构体的静态方法使用的关键字是static,类的静态方法使 ...