Codeforces Gym101606 E.Education (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
E Education
这个题有点意思,就是找满足条件的最小价格里的最大值的人数,有点贪心的思想吧,一开始写错了,人群的那个不能排序,而且是最小价格里找能住下人最多的部门,让这个部门去住这个房间。在循环的时候处理一下,找出来符合条件的人群的最大数就可以了。代码写的巨丑。。。
代码:
1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 #include<queue>
6 #include<set>
7 #include<algorithm>
8 #include<map>
9 using namespace std;
10 const int INF=0x3f3f3f3f;
11 struct node{
12 int n;
13 int m;
14 int pos;
15 int flag;
16 }a[100000];
17 bool cmp(node a,node b){
18 return a.m<b.m;
19 }
20 int s[100000];
21 int ans[100000];
22 int flagg[100000];
23 int main(){
24 int d,b;
25 while(~scanf("%d%d",&d,&b)){
26 memset(flagg,0,sizeof(flagg));
27 for(int i=0;i<d;i++){
28 scanf("%d",&s[i]);
29 flagg[i]=1;
30 }
31 for(int i=0;i<b;i++){
32 a[i].pos=i+1;
33 a[i].flag=1;
34 }
35 for(int i=0;i<b;i++)
36 scanf("%d",&a[i].n);
37 for(int i=0;i<b;i++)
38 scanf("%d",&a[i].m);
39 sort(a,a+b,cmp);
40 int h=0;
41 for(int j=0;j<b;j++){
42 int maxx=-INF;int situ=-1;int ret=-1;
43 for(int i=0;i<d;i++){
44 if(a[j].n>=s[i]&&a[j].flag==1&&flagg[i]==1){
45 if(maxx<s[i]){
46 maxx=s[i];
47 ret=i;
48 situ=j;
49 }
50 }
51 }
52 if(ret!=-1){
53 ans[ret]=a[situ].pos;
54 a[situ].flag=0;
55 flagg[ret]=0;
56 h++;
57 }
58 }
59 if(h<d)printf("impossible\n");
60 else{
61 for(int i=0;i<d;i++){
62 printf("%d",ans[i]);
63 if(i!=d-1)printf(" ");
64 else printf("\n");
65 }
66 }
67 }
68 return 0;
69 }
Codeforces Gym101606 E.Education (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))的更多相关文章
- Codeforces Gym101606 A.Alien Sunset (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017) 寒假第一次组队训练赛,和学长一起训练,题目难度是3颗星,我和猪队友写 ...
- Codeforces Gym101606 C.Cued In (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
C Cued In 这个题是打球的.都忘了写的什么了... 代码: 1 #include<iostream> 2 #include<cstring> 3 #include< ...
- Codeforces Gym101606 J.Just A Minim (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
J Just A Minim 超级无敌大水题,但是被精度卡了一手,输出要精确到小数点后6位,我直接输出的... 代码: 1 #include<iostream> 2 #include< ...
- Codeforces Gym101606 I.I Work All Day (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
I I Work All Day 这个题就是取模找最小的. 代码: 1 #include<iostream> 2 #include<cstdio> 3 #include< ...
- Codeforces Gym101606 D.Deranging Hat (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
D Deranging Hat 这个题简直了,本来想的是冒泡排序然后逆着输出来的,后来发现不对,因为题目上求的是最优解,而且冒泡的话,输出结果有的超出10000行了,所以就是把一开始的,排好序的字母标 ...
- [寒假集训第一场]gym101606 2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017)
3星场 难度在于英文题面太难读懂了QAQ 看样例猜题意的我 博客园的c++主题真丑 A Alien Sunset \(description\) 有\(n\)个星球,每个星球自转时间不一样,所以一天的 ...
- 2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017)
A. Alien Sunset 暴力枚举答案即可. #include<cstdio> int n,i,mx; struct P{ int h,r,t; bool night(int x){ ...
- 2019.04.11 第四次训练 【 2017 United Kingdom and Ireland Programming Contest】
题目链接: https://codeforces.com/gym/101606 A: ✅ B: C: ✅ D: ✅ https://blog.csdn.net/Cassie_zkq/article/ ...
- 2017 United Kingdom and Ireland Programming(Gym - 101606)
题目很水.睡过了迟到了一个小时,到达战场一看,俩队友AC五个了.. 就只贴我补的几个吧. B - Breaking Biscuits Gym - 101606B 旋转卡壳模板题.然后敲错了. 代码是另 ...
随机推荐
- Linux菜鸟起飞之路【六】权限管理(二)
一.权限信息详解 ls -l 文件 //查看文件权限写法1 ll 文件 //查看文件权限写法2 ls -dl 目录 //查看目录权限写法1 ll -d 目录 //查看目录权限写法2 文件权限格式: ...
- 02 Django模型
ORM 的作用 ORM 作用示意图 ORM 框架的功能 建立模型类和表之间的对应关系,允许通过面向对象的方式来操作数据库 根据设计的模型类生成数据库中的表格. 通过方便的配置就可以进行数据库的切换 数 ...
- 使用Github第一节
学习Github 1.目的: 借助github托管代码 2.基本概念(1): 仓库(Repository) 仓库用来存放项目代码,每个项目对应一个仓库,多个项目则对应多个仓库 收藏(Start) 收藏 ...
- python3爬取豆瓣top250电影
需求:爬取豆瓣电影top250的排名.电影名称.评分.评论人数和一句话影评 环境:python3.6.5 准备工作: 豆瓣电影top250(第1页)网址:https://movie.douban.co ...
- graph-Dijkstra's shortest-path alogorithm
直接贴代码吧,简明易懂. 后面自己写了测试,输入数据为: a b c d e 0 1 4 0 2 2 1 2 3 1 3 2 1 4 3 2 1 1 2 3 4 2 4 5 4 3 1 也就是课本上1 ...
- how to setting a i2c driver
How to instantiate I2C devices============================== Unlike PCI or USB devices, I2C devices ...
- ProC第二弹
一.提要 上文简单介绍了Windows下ProC配置开发,这次我们使用Linux平台再次配置Oracle ProC开发环境(RedHat Linux 9 + Oracle 92). <OR ...
- The 2018 ACM-ICPC China JiangSu Provincial Programming Contest I. T-shirt
JSZKC is going to spend his vacation! His vacation has N days. Each day, he can choose a T-shirt to ...
- Java学习——面对对象的思想入门
本文是看过<head first Java>之后的一点感悟,写点东西帮忙以后回忆,Java目前在我的工作中用到还不多,而我又对面对对象的编程非常的感兴趣.曾经在MFC平台上写过 ...
- 修改Echarts 图表的坐标轴的文本的排列位置
option.xAxis.axisLabel['interval'] = 0 option.xAxis.axisLabel['formatter'] = function(value,index){ ...