【PAT甲级】1080 Graduate Admission (30 分)
题意:
输入三个正整数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 分)的更多相关文章
- 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甲级1080 Graduate Admission【模拟】
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136 题意: 模拟高考志愿录取. 考生根据总 ...
- 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 ...
- PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***
1049 Counting Ones (30 分) The task is simple: given any positive integer N, you are supposed to co ...
- 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 ...
- PAT 甲级 1026 Table Tennis (30 分)(坑点很多,逻辑较复杂,做了1天)
1026 Table Tennis (30 分) A table tennis club has N tables available to the public. The tables are ...
- PAT 甲级 1022 Digital Library (30 分)(字符串读入getline,istringstream,测试点2时间坑点)
1022 Digital Library (30 分) A Digital Library contains millions of books, stored according to thei ...
- PAT 1080. Graduate Admission (30)
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...
随机推荐
- Openstack 简单梳理,(自用 慎点)
这个图里面的彩色方块,就是OpenStack最核心的组件. 推荐几个大咖,大家可以百度找他们的博客来看:陈沙克.何明桂.孔令贤,Cloudman.
- python3练习100题——012
今天继续,答案都通过py3测试. 原题链接:http://www.runoob.com/python/python-exercise-example12.html 题目:判断101-200之间有多少个 ...
- node安装升级过程中遇到的问题汇总
一.Node already installed, it's just not linked 第一步:sudo chown -R $(whoami) $(brew --prefix)/* 第二步:br ...
- keil密钥过期 新注册机 有效期至2032年
点击下载:keil注册机至2032年
- Iris路由和路由组
package main import ( "github.com/kataras/iris" "github.com/kataras/iris/context" ...
- 传奇服务端添加双倍经验卷的方法 双倍经验卷轴DB示例展示
第一步我们在DBC数据库中添加好双倍经验卷轴DB,以下是现成的双倍经验卷DB,导入到DB里面就可以了. 222;双倍经验卷;31;0;1;20;0;0;265;0;0;0;0;0;0;0;0;0;0; ...
- bootstrap的字体设置
@font-face { font-family: 'Glyphicons Halflings'; src: url('../fonts/glyphicons-halflings-regular.eo ...
- php对字符串的操作
php最文字的处理很是强大,之前一直云里雾里,这次学习一下. 1,' 与 ”的区别 <?php //双引号中的特殊字符会被解析 echo "你好\t我好";echo &quo ...
- dw选择器
选择器并没有一个固定的定义,在某种程度上说,jQuery的选择器和样式表中的选择器十分相似.选择器具有如下特点:1.简化代码的编写2.隐式迭代3.无须判断对象是否存在jQuery 的选择器可谓之强大无 ...
- AcWing 859. Kruskal算法求最小生成树 稠密图
//稠密图 #include <cstring> #include <iostream> #include <algorithm> using namespace ...