博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
九度oj 1005 Graduate Admission
阅读量:7071 次
发布时间:2019-06-28

本文共 4095 字,大约阅读时间需要 13 分钟。

这一题我写了三个半小时。哈哈   哈哈  呸   想死的心都有了。

看了     深受启发,才会出了这一道题

题目描述:

    It is said that in 2011, there are 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.

输入:

    Each input file may contain more than 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.

输出:

    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.

#include 
#include
using namespace std; struct stu{ int num; int GE; int GL; int ave; int select[5]; //志愿 int elected; //录取结果}; struct school{ int Quota; //名额 int ave; //平均分数线 int GE; //GE分数线 int amount;}; bool cmp1(const stu a,const stu b){ if(a.ave!=b.ave) return a.ave>b.ave; //当平均分不等时,按平均值排序(从大到小) else return a.GE>b.GE; //否则按GE} bool cmp2(const stu a,const stu b){ return a.num
>n>>m>>k) { school* mschool=new school[m]; stu* stud=new stu[n]; for(int i=0; i
>mschool[i].Quota; mschool[i].ave=-1; //分数线 mschool[i].GE=-1; //分数线 mschool[i].amount=0; } for(int i=0; i
>stud[i].GE>>stud[i].GL; stud[i].ave=(stud[i].GE+stud[i].GL)/2; for(int j=0; j
>stud[i].select[j]; stud[i].elected=-1; } sort(stud,stud+n,cmp1); //按平均成绩和GE成绩排序 for(int i=0; i
0) { if(mschool[NUM].Quota==1) //只有当school的名额为1是才记录该学生的成绩,作为录取分数线 { mschool[NUM].ave=stud[i].ave; mschool[NUM].GE=stud[i].GE; } stud[i].elected=NUM; //记录该学生的录取结果 mschool[NUM].Quota--; mschool[NUM].amount++; break;//啊啊啊!注意!!被录取后该同学应该跳出循环,不能再被其他大学录取 } else if(mschool[NUM].Quota==0) { if(stud[i].ave==mschool[NUM].ave&&stud[i].GE==mschool[NUM].GE) { stud[i].elected=NUM; mschool[NUM].amount++; break;//啊啊啊!注意!!被录取后该同学应该跳出循环,不能再被其他大学录取 } else mschool[NUM].Quota--; } } } sort(stud,stud+n,cmp2);//为了升序输出 for(int i=0; i

转载于:https://www.cnblogs.com/zhanyeye/p/9746126.html

你可能感兴趣的文章
Linux性能监测
查看>>
Excel自动生成工资条格式
查看>>
linux java环境变量设置
查看>>
Git 处理分支冲突 rebase
查看>>
Java设计模式之工厂模式
查看>>
测试经理能力要求
查看>>
linux修改用户密码的问题
查看>>
组策略应用之一:映射网络驱动器
查看>>
java第四次作业
查看>>
Dynamics CRM 请求服务时报access is denied错误
查看>>
Oracle in与exists语句
查看>>
我的友情链接
查看>>
通过文件句柄获取文件的路径
查看>>
【转】什么是非对称加密、数字签名、数字证书
查看>>
2015-06-30(最新)手机号正则表达式- 校验示例
查看>>
spring-mvc 3.* 多视图解析配置实例 ContentNegotiatingViewResolver
查看>>
09.移动先行之谁主沉浮----控件之轮流轰炸——高级控件
查看>>
Python3 与 C# 扩展之~基础衍生
查看>>
完全数
查看>>
HDU2017多校联合 contest 2
查看>>