1080. Graduate Admission (30)

时间:2022-11-01 11:27:28
时间限制
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&period; Graduate Admission &lpar;30&rpar;

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

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

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

  3. PAT 1080&period; Graduate Admission &lpar;30&rpar;

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

  4. 1080 Graduate Admission &lpar;30&rpar;(30 分)

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

  5. PAT &lpar;Advanced Level&rpar; 1080&period; Graduate Admission &lpar;30&rpar;

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

  6. 1080&period; Graduate Admission &lpar;30&rpar;-排序

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

  7. 【PAT甲级】1080 Graduate Admission &lpar;30 分&rpar;

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

  8. pat1080&period; Graduate Admission &lpar;30&rpar;

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

  9. PAT 1080 Graduate Admission&lbrack;排序&rsqb;&lbrack;难&rsqb;

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

随机推荐

  1. jquery中隐藏div的几种方法

    //jQuery中的显示.隐藏方法 $("#id").show()://表示display:block,    $("#id").hide()://表示disp ...

  2. UI培训怎么学才高效

    随着互联网科技的爆炸式发展,UI设计越来越受到我们的青睐,绝大部分企业已成立U设计部门来提高自身影响力,但现在许多从事UI设计的人,都是从零基础过度过来的,他们不乏大牛,在阿里巴巴,在腾讯等国内一流企 ...

  3. Sublime codeIntel 配置支持php自动提示

    Sublime codeIntel 配置支持php自动提示 下载地址:https://github.com/SublimeCodeIntel/SublimeCodeIntel 安装方法:下载后放到su ...

  4. 利用WinRAR命令行压缩文件或文件夹

    压缩文件夹winrar.exe a -ag -k -r -s -ibck c:/bak.rar c:/dat/ 压缩多个文件winrar a -ag -ibck bak.rar filename1 f ...

  5. MySql数据库学习笔记&lpar;3&rpar;

    查看默认事务隔离级别 mysql> select @@tx_isolation; mysql> select @@global.tx_isolation; mysql> select ...

  6. openstack 安全策略权限控制等api接口

    computer API:                创建安全组 /os-security-groups 创建安全组规则 /os-security-group-default-rules Netw ...

  7. Docker技术综述

    从技术入门到实战:docker初步尝试 docker中文社区 容器和镜像的导入和导出

  8. WordPress 3&period;8 后台仪表盘将重新设计

    WordPress 3.8 的后台仪表盘界面将会重新设计 概况(RightNow) -> 改为网站内容(SiteContent) 快速发布(QuickPress) -> 改为快速草稿(Qu ...

  9. linux 中 virtualenvwrapper的使用

    原文链接:http://www.jianshu.com/p/3abe52adfa2b Virtaulenvwrapper Virtaulenvwrapper是virtualenv的扩展包,用于更方便管 ...

  10. iis服务器php环境 failed to open stream&colon; No such file or directory解决办法

    项目主机用的windows系统,iis服务器:远程连接桌面—>本地资源->映射D盘驱动器,将本地d盘修改后的文件放在远程主机项目目录里,访问报出failed to open stream: ...