题意:

输入三个正整数N,M,K(N<=40000,M<=100,K<=5)分别表示学生人数,可供报考学校总数,学生可填志愿总数。接着输入一行M个正整数表示从0到M-1每所学校招生人数,N行数据分别包括两个成绩和K个志愿。输出M行依照平行志愿原则输出每所学校录取的学生序号,如果成绩相同,可以突破计划招生人数。

trick:

不是很懂为什么当我输出的时候采用if(i>0)cout<<"\n";会导致测试点2和4格式错误。。。。。

发现最后一行必须要换行。。。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
typedef struct student{
int x,y;
int id;
int c[];
};
student d[];
int a[];
int b[];
vector<int>ans[];
bool cmp(student a,student b){
if(a.x+a.y!=b.x+b.y)
return a.x+a.y>b.x+b.y;
return a.x>b.x;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m,k;
cin>>n>>m>>k;
for(int i=;i<m;++i)
cin>>a[i];
for(int i=;i<n;++i){
cin>>d[i].x>>d[i].y;
for(int j=;j<=k;++j)
cin>>d[i].c[j];
d[i].id=i;
}
sort(d,d+n,cmp);
int tamp=-;
for(int i=;i<n;++i){
if(i>&&d[i].x+d[i].y<d[i-].x+d[i-].y)
tamp=-;
for(int j=;j<=k;++j){
if(a[d[i].c[j]]){
--a[d[i].c[j]];
ans[d[i].c[j]].push_back(d[i].id);
tamp=d[i].c[j];
break;
}
else if(d[i].c[j]==tamp&&d[i].y==d[i-].y&&d[i].x==d[i-].x){
ans[tamp].push_back(d[i].id);
break;
}
}
}
for(int i=;i<m;++i)
sort(ans[i].begin(),ans[i].end());
for(int j=;j<ans[].size();++j){
if(j>)
cout<<" ";
cout<<ans[][j];
}
for(int i=;i<m;++i){
cout<<"\n";
for(int j=;j<ans[i].size();++j){
if(j>)
cout<<" ";
cout<<ans[i][j];
}
}
cout<<endl;
return ;
}

【PAT甲级】1080 Graduate Admission (30 分)的更多相关文章

  1. PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)

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

  2. pat 甲级 1080. Graduate Admission (30)

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

  3. PAT甲级1080 Graduate Admission【模拟】

    题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136 题意: 模拟高考志愿录取. 考生根据总 ...

  4. PAT 甲级 1072 Gas Station (30 分)(dijstra)

    1072 Gas Station (30 分)   A gas station has to be built at such a location that the minimum distance ...

  5. PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***

    1049 Counting Ones (30 分)   The task is simple: given any positive integer N, you are supposed to co ...

  6. PAT 甲级 1030 Travel Plan (30 分)(dijstra,较简单,但要注意是从0到n-1)

    1030 Travel Plan (30 分)   A traveler's map gives the distances between cities along the highways, to ...

  7. PAT 甲级 1026 Table Tennis (30 分)(坑点很多,逻辑较复杂,做了1天)

    1026 Table Tennis (30 分)   A table tennis club has N tables available to the public. The tables are ...

  8. PAT 甲级 1022 Digital Library (30 分)(字符串读入getline,istringstream,测试点2时间坑点)

    1022 Digital Library (30 分)   A Digital Library contains millions of books, stored according to thei ...

  9. PAT 1080. Graduate Admission (30)

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

随机推荐

  1. oracle 启动

    Oracle数据库启动过程及状态详解(nomount.mount和open) 先来简要了解一下Oracle数据库体系架构以便于后面深入理解,Oracle Server主要由实例(instance)和数 ...

  2. python hashlib 详解

    1.概述 摘要算法简介 Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢?摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定 ...

  3. PyQt5学习笔记-从主窗体打开一个子窗体

    PyQt5学习笔记-从主窗体打开一个子窗体 软件环境: Eric6+Python3.5+PyQt5 试验目标: 1.点击菜单项Open,打开一个子窗体 2.点击按钮Open,打开一个子窗体 主窗体设计 ...

  4. Python_面向对象进阶

    isinstance和issubclass isinstance(obj,cls)检查是否obj是否是类 cls 的对象 class Foo(object): pass obj = Foo() isi ...

  5. ZooKeeper Distributed lock

    https://segmentfault.com/a/1190000016351095 http://www.dengshenyu.com/java/%E5%88%86%E5%B8%83%E5%BC% ...

  6. HTML学习(17)URL

    HTML 统一资源定位器(Uniform Resource Locators) URL - 统一资源定位器 Web浏览器通过URL从Web服务器请求页面. scheme://host.domain:p ...

  7. GOM引擎脚本 时间段内调整人物属性

    功能: 调整人物属性 格式: ChangeHumAbility 属性(1-20) 操作符(+ = -) 效果(1-65535) 时间秒说明: 属性1-12分别对应人物 防御下限 防御上限 魔御下限 魔 ...

  8. 445. 两数相加 II

    Q: A: 这种题的用例是一定会搞一些很大的数的.long都会溢出,所以我们就不用尝试转数字做加法转链表的方法了.另外直接倒置两个链表再做加法的做法会改变原链表,题干也说了禁止改动原链表. 1.求两个 ...

  9. ThinkPhp5 中Volist标签的用法

    Volist标签一般是和内置方法assign()搭配使用,将值从后台传到前台,是当下比较流行的一种传值方法 本文实例讲述了ThinkPHP模板循环输出Volist标签用法.分享给大家供大家参考,具体如 ...

  10. IntelliJ IDEA 2017.3尚硅谷-----设置字体大小行间距