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))的更多相关文章

  1. Codeforces Gym101606 A.Alien Sunset (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))

    2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017) 寒假第一次组队训练赛,和学长一起训练,题目难度是3颗星,我和猪队友写 ...

  2. 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< ...

  3. 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< ...

  4. 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< ...

  5. Codeforces Gym101606 D.Deranging Hat (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))

    D Deranging Hat 这个题简直了,本来想的是冒泡排序然后逆着输出来的,后来发现不对,因为题目上求的是最优解,而且冒泡的话,输出结果有的超出10000行了,所以就是把一开始的,排好序的字母标 ...

  6. [寒假集训第一场]gym101606 2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017)

    3星场 难度在于英文题面太难读懂了QAQ 看样例猜题意的我 博客园的c++主题真丑 A Alien Sunset \(description\) 有\(n\)个星球,每个星球自转时间不一样,所以一天的 ...

  7. 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){ ...

  8. 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/ ...

  9. 2017 United Kingdom and Ireland Programming(Gym - 101606)

    题目很水.睡过了迟到了一个小时,到达战场一看,俩队友AC五个了.. 就只贴我补的几个吧. B - Breaking Biscuits Gym - 101606B 旋转卡壳模板题.然后敲错了. 代码是另 ...

随机推荐

  1. 如何用 CSS 和 D3 创作火焰动画

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/xJdVxx 可交互视频 ...

  2. 文件处理seek以及修改内容的两种方式

    f.seek(offset,whence)offset代表文件的指针的偏移量,单位是字节byteswhence代表参考物,有三个取值# 0:参照文件的开头# 1:参照当前文件指针所在位置# 2: 参照 ...

  3. STA basic

  4. wamp开发环境配置之配置Apache虚拟主机

    网站建设人员在本地测试时,常常不是一个网站,那怎么能像输入域名一样在地址栏上面输入“域名”就能本地访问该网站呢?这里就要配置Apache虚拟主机了! 1.找到apache\conf\httpd.con ...

  5. Lecture 3

    surface models 1. The two main methods of creating surface models are interpolation and triangulatio ...

  6. JFinal 结合Dubbo发生的一些问题

    1.java.lang.NoSuchMethodError: org.jboss.resteasy.specimpl.BuiltResponse.getHeaders()Ljavax/ws/rs/co ...

  7. python基础学习笔记——循环语句(while、for)

    while 循环 流程控制语句 while 1.基本循环 while 条件: # 循环体 # 如果条件为真,那么循环则执行 # 如果条件为假,那么循环不执行   2.break break 用于退出当 ...

  8. MySQL中的DDL(Data Definition Language,数据定义语言)

    create(创建表) 标准的建表语句: create table [模式名.]表名 ( #可以有多个列定义 columnName1 dataType [default expr(这是默认值)], . ...

  9. C语言的文件处理

    所谓“文件”一般指存储在外部介质上数据的集合.根据数据的组织形式,可分为ASCII文件和二进制文件.ASCII文件,又称为文本文件,它的每一个字节存放一个ASCII代码,代表一个字符.二进制文件是把内 ...

  10. [错误处理]python大小写敏感,关键字不要写错

    今天调试程序,发现了一个极为隐蔽的bug. True False关键字大小写写错了,然后半天没找出问题所在.