PAT甲级1080 Graduate Admission【模拟】
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136
题意:
模拟高考志愿录取。
考生根据总成绩和高考成绩排名。根据排名往下录取,每个人有k个志愿。
如果他填的学校名额没有满,那么就可以被录取。如果他填的学校名额满了,最后一名的排名和这个人是一样的话,就可以被录取。
思路:
直接模拟。
刚开始居然有一个数据超时了,把排序的cmp里面改成传引用居然就过了。
- //#include<bits/stdc++>
- #include<stdio.h>
- #include<iostream>
- #include<algorithm>
- #include<cstring>
- #include<stdlib.h>
- #include<queue>
- #include<map>
- #include<stack>
- #include<set>
- #define LL long long
- #define ull unsigned long long
- #define inf 0x3f3f3f3f
- using namespace std;
- int n, m, k;
- const int maxn = 4e4 + ;
- struct student{
- int ge, gi;
- int id;
- int gfinal;
- vector<int>apply;
- }stu[maxn];
- bool cmp(student &a, student &b)
- {
- if(a.gfinal == b.gfinal){
- return a.ge > b.ge;
- }
- else return a.gfinal > b.gfinal;
- }
- struct school{
- int quota;
- vector<student>addmit;
- }sch[];
- bool cmpans(student &a, student &b)
- {
- return a.id < b.id;
- }
- int main()
- {
- scanf("%d%d%d", &n, &m, &k);
- for(int i = ; i < m; i++){
- scanf("%d", &sch[i].quota);
- }
- for(int i = ; i < n; i++){
- stu[i].id = i;
- scanf("%d%d%", &stu[i].ge, &stu[i].gi);
- stu[i].gfinal = (stu[i].ge + stu[i].gi) / ;
- for(int j = ; j < k; j++){
- int s;
- scanf("%d", &s);
- stu[i].apply.push_back(s);
- }
- }
- sort(stu, stu + n, cmp);
- for(int i = ; i < n; i++){
- for(int j = ; j < k; j++){
- int s = stu[i].apply[j];
- if(sch[s].quota){
- sch[s].addmit.push_back(stu[i]);
- sch[s].quota--;
- break;
- }
- else{
- if(sch[s].addmit.size()){
- student lastone = sch[s].addmit.back();
- if(lastone.gfinal == stu[i].gfinal && lastone.ge == stu[i].ge){
- sch[s].addmit.push_back(stu[i]);
- break;
- }
- }
- }
- }
- }
- for(int i = ; i < m; i++){
- if(sch[i].addmit.size()){
- sort(sch[i].addmit.begin(), sch[i].addmit.end(), cmpans);
- printf("%d", sch[i].addmit[].id);
- for(int j = ; j < sch[i].addmit.size(); j++){
- printf(" %d", sch[i].addmit[j].id);
- }
- }
- printf("\n");
- }
- return ;
- }
PAT甲级1080 Graduate Admission【模拟】的更多相关文章
- 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)
1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- PAT甲级——A1080 Graduate Admission
It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applicati ...
- 1080 Graduate Admission——PAT甲级真题
1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were about 100 graduate schools rea ...
- PAT 1080 Graduate Admission[排序][难]
1080 Graduate Admission(30 分) It is said that in 2011, there are about 100 graduate schools ready to ...
- 【PAT甲级】1080 Graduate Admission (30 分)
题意: 输入三个正整数N,M,K(N<=40000,M<=100,K<=5)分别表示学生人数,可供报考学校总数,学生可填志愿总数.接着输入一行M个正整数表示从0到M-1每所学校招生人 ...
- PAT 1080. Graduate Admission (30)
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...
- PAT 1080. Graduate Admission
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 ...
随机推荐
- CentOS 7 安装 Oracle 11.2.0.4
一.安装环境 CentOS Linux release 7.2.1511 (Core) Oracle Database 11g Release 2 (11.2.0.4) 二.安装前准备 2.1 修改主 ...
- PowerShell 显示气球提示框 2
https://www.itninja.com/blog/view/reboot-required-toast-notifications-for-windows-machines [void][Sy ...
- 使用 TRESTClient 与 TRESTRequest 作为 HTTP Client(转)
使用 TRESTClient 与 TRESTRequest 作为 HTTP Client 转自:http://www.cnblogs.com/dennieschang/p/6966403.html ...
- java mqtt
代码: package cc.gongchang.mqtt; import java.net.URISyntaxException; import org.fusesource.hawtdispatc ...
- lua 源码分析之线程对象lua_State
lua_State 中放的是 lua 虚拟机中的环境表.注册表.运行堆栈.虚拟机的上下文等数据. 从一个主线程(特指 lua 虚拟机中的线程,即 coroutine)中创建出来的新的 lua_Stat ...
- NoSuchMethodError: The getter 'inputs' was called on null.
I get this message : You have hit a bug in build_runner Please file an issue with reproduction steps ...
- 深入理解linux系统下proc文件系统内容
深入理解linux系统下proc文件系统内容 内容摘要:Linux系统上的/proc目录是一种文件系统,即proc文件系统. Linux系统上的/proc目录是一种文件系统,即proc文件系统.与其它 ...
- MySql基本查询、连接查询、子查询、正则表达查询解说
林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 查询数据指从数据库中获取所须要的数据.查询数据是数据库操作中最经常使用,也是最重要的操作.用户 ...
- 转:图像处理、显示中的行宽(linesize)、步长(stride)、间距(pitch)
在图像数据传输和显示的过程中有一个不常用的参数:间距. 间距的名称: 它有很多的别名,在使用d3d显示的时候,它叫pitch:在用ffmpeg解码的时候,它叫linesize: 在用ffmpeg转换格 ...
- Software Engineer Title Ladder
http://changelog.ca/log/2013/08/09/software_engineer_title_ladder Within the software engineering pr ...