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. 批量ping IP并检测IP延迟率和丢包率脚本

    脚本文件如下: #!/bin/bash #Author:Mr.Ding #Created Time:2018-08-26 07:23:44 #Name:ping.sh #Description: sh ...

  2. vue-highlightjs的使用小结

    万能的github真主,让我们强大!在vue的项目中想使用highlight.js这样的代码高亮?有人帮助我们实现了vue-highlightjs 安装 yarn add highlight.js - ...

  3. asp发送短信验证码 pst方式

    <script language="jscript" runat="server">  Array.prototype.get = function ...

  4. JAVA基础篇—HashMap

    /class Depositor package 银行储户; public class Depositor { private String id; private String name; priv ...

  5. LeetCode(220) Contains Duplicate III

    题目 Given an array of integers, find out whether there are two distinct indices i and j in the array ...

  6. zoj 4057

    #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> ...

  7. Django基于Pycharm开发之二 [使用django adminSite]

    在使用django自带的adminsite的时候,有以下内容需要做. 1.数据迁移,管理表的创建. 2.启用本地化 (setting.py的配置) 一.数据迁移,默认情况下,安装django之后,dj ...

  8. 【转】LAMP网站架构方案分析【精辟】

    [转]LAMP网站架构方案分析[精辟] http://www.cnblogs.com/mo-beifeng/archive/2011/09/13/2175197.html Xubuntu下LAMP环境 ...

  9. FastText 介绍

    FastText 介绍 在面试百度的NLP工程师时,被问及常用的词向量表示学习方法有哪些,我说知道word2vec,然后大佬又问我知道FastText么... 这就很尴尬了,不会! 不同于word2v ...

  10. Codeforces Round #410 (Div. 2) B. Mike and strings

    B. Mike and strings time limit per test 2 seconds memory limit per test 256 megabytes input standard ...