题目链接: 点击打开链接

题目描述:

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.

样例输入:
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
样例输出:
0 10
3
5 6 7
2 81 4
思路:主要是按照题目要求堆代码,算法难度不高
code:
#include <bits/stdc++.h>
using namespace std ;
class student{public :int id ;float GE,GI,Final ;int zy[5] ;
};
bool compare (const student & a, const student &b){return a.id<b.id ;
}
class school{public :int quota , curNum; // 学校招生指标人数  已招生人数student *stu;school(){}void nschool(int quota){this->quota = quota;curNum = 0 ;stu = new student[quota+5];}bool acceptStu(student student){if (curNum<quota){stu[curNum++] = student;return true;}else {if (student.GE==stu[curNum-1].GE && student.GI == stu[curNum-1].GI){stu[curNum++] = student;return false ;}else{return false ;}}}~school(){delete []stu;}
};
bool cmp(const student &a , const student &b){if (a.Final!=b.Final)return (a.Final-b.Final)>0;return (a.GE - b.GE)>0 ;
}
int main (){int n,m,k;school * sch;student *stu ;while (cin>>n>>m>>k){int quota ;sch = new school[m];for (int i = 0 ; i < m ; ++i ){cin>>quota ;sch[i].nschool(quota);}stu = new student[n] ;for (int i= 0 ; i < n ; ++i){stu[i].id = i ;cin>>stu[i].GE>>stu[i].GI;stu[i].Final = (stu[i].GE+stu[i].GI)/2;for (int j = 0 ; j < k ;++j)cin>>stu[i].zy[j] ;}sort(stu , stu+n,cmp);for (int i = 0 ; i < n ; ++i){for(int j = 0 ; j < k ;++j){if (sch[stu[i].zy[j]].acceptStu(stu[i]))break;}}for (int i = 0 ; i < m ; ++i){if (sch[i].curNum==0)cout<<endl;else{sort(sch[i].stu,sch[i].stu+(sch[i].curNum), compare);for (int j = 0 ; j<sch[i].curNum ; ++j){cout<<sch[i].stu[j].id;if (j==sch[i].curNum-1)cout<<endl;elsecout<<" ";}}}delete []stu;delete []sch;}return 0;
}

九度OJ 1005 Graduate Admission相关推荐

  1. 打不开磁盘配额linux,九度OJ 1455 珍惜现在,感恩生活 -- 动态规划(背包问题)...

    题目描述: 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买.请问:你用有限的资金最 ...

  2. Freckles - 九度 OJ 1144

    Freckles - 九度 OJ 1144 题目 时间限制:1 秒 内存限制:128 兆 特殊判题:否 题目描述: In an episode of the Dick Van Dyke show, l ...

  3. 非常可乐(九度 OJ 1457)

    非常可乐(九度 OJ 1457) 时间限制:1 秒 内存限制:32 兆 特殊判题:否 1.题目描述: 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是 seeyou 却不这么认为.因为每次当 see ...

  4. 九度OJ 题目1179:阶乘

    /********************************* * 日期:2013-2-8 * 作者:SJF0115 * 题号: 九度OJ 题目1179:阶乘 * 来源:http://ac.jo ...

  5. 九度OJ——1028继续畅通工程

    题目描述: 省政府"畅通工程"的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可).现得到城镇道路统计表,表中列出了任意两城镇间修 ...

  6. Leagal or Not - 九度 OJ 1448

    Leagal or Not - 九度 OJ 1448 题目 时间限制:1 秒 内存限制:128 兆 特殊判题:否 题目描述: ACM-DIY is a large QQ group where man ...

  7. 九度OJ 题目1069:查找学生信息 随笔

    ** 九度OJ 题目1069:查找学生信息 ** 题目描述如下: 输入N个学生的信息,然后进行查询. 输入 输入的第一行为N,即学生的个数(N<=1000) 接下来的N行包括N个学生的信息,信息 ...

  8. 九度OJ 题目1203:IP地址

    /********************************* * 日期:2013-2-8 * 作者:SJF0115 * 题号: 九度OJ 题目1203:IP地址 * 来源:http://ac. ...

  9. 九度OJ 1024 畅通工程 -- 并查集、贪心算法(最小生成树)

    题目地址:http://ac.jobdu.com/problem.php?pid=1024 题目描述: 省政府"畅通工程"的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有 ...

最新文章

  1. [待总结]高频率vim命令
  2. 人工智能带来科技浪潮的同时,对相关法治领域提出了什么样的挑战?
  3. c#(winform)中ComboBox和ListBox添加项完全解决
  4. 数据库事务的四大特征
  5. PHP的global与GLOBAL
  6. SAP Cloud Application Programming bookshop 例子 Vue页面不能正常显示的原因分析
  7. 用c语言绘制自定义图形,Android使用自定义View绘图
  8. 修改console缓存大小_更改缓存的行大小将如何影响其他参数?
  9. 微商相册一直显示服务器偷懒,【小程序】微商个人相册多端小程序源码以及安装...
  10. python免费全套教程-2020全网 最详细的Python入门教程完整版,无偿分享,收藏
  11. HMC 命令行登陆设置
  12. Linux下MySQL的简单使用(一)
  13. 【图像加密】基于matlab DNA混沌系统图像加密【含Matlab源码 1190期】
  14. 汉字转拼音(同音异形)-工具
  15. AspnetPager
  16. RAdam和LookAhead合二为一
  17. MyBatis入门到精通
  18. 为什么阿里不允许用Executors创建线程池,而是通过ThreadPoolExecutor的方式?
  19. java秃顶_【本人秃顶程序员】在Java中使用函数范式提高代码质量
  20. 企业微信又更新了!聊天敏感词、下载直播回放视频、聊天文件支持10GB...

热门文章

  1. 没人性!让我们这么早来上班
  2. 经典面试题(11):关于变量提升,以下代码将输出什么?
  3. 大数据时代,前端开发者该如何提升自身竞争力(附教程视频)
  4. 又一个被JavaScript攻占的领域:物联网
  5. 请说说你对标签语义化的理解?
  6. element提交图片限制一张_科研SCI论文图片常见问题和错误汇总
  7. 哈佛大学单细胞课程|笔记汇总 (三)
  8. guid怎么做到唯一_怎么做成为一个好女人呢?
  9. 信奥中的数学:孙子定理 中国剩余定理
  10. 第25课 成绩等级 《小学生C++趣味编程》