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 旋转卡壳模板题.然后敲错了. 代码是另 ...
随机推荐
- overtrue/wechat 包 由 sys_get_temp_dir 引发的 the directory "c:\Windows" is not writable
vendor\overtrue\wechat\src\Foundation\Application.php registerBase 方法 在初始化属性时 $this['cache'] = funct ...
- 初学Python02
数据类型和变量: 1.整数 整数在Python中直接输入就好,没有特殊要求(正负整数皆可).由于计算机是二进制的,有时候会使用十六进制表示数字,0X+0-9或者a-f来表示. 2.浮点数 浮点数 ...
- Python语言程序设计之二--用turtle库画围棋棋盘和正、余弦函数图形
这篇笔记依然是在做<Python语言程序设计>第5章循环的习题.其中有两类问题需要记录下来. 第一是如何画围棋棋盘.围棋棋盘共有19纵19横.其中,位于(0,0)的星位叫天元,其余8个星位 ...
- FSMC原理通俗解释
所以不用GPIO口直接驱动液晶,是因为这种方法速度太慢,而FSMC是用来外接各种存储芯片的,所以其数据通信速度是比普通GPIO口要快得多的.TFT-LCD 驱动芯片的读写时序和SRAM的差不多,所以就 ...
- CodeForces 14D 树的直径 Two Paths
给出一棵树,找出两条不相交即没有公共点的路径,使得两个路径的长度的乘积最大. 思路:枚举树中的边,将该边去掉,分成两棵树,分别求出这两棵树的直径,乘起来维护一个最大值即可. #include < ...
- HDU 5378 树上的概率DP Leader in Tree Land
官方题解: 可以用求概率的思想来解决这个问题.令以i号节点为根的子树为第i棵子树,设这颗子树恰好有sz[i]个点.那么第i个点是第i棵子树最大值的概率为1/sz[i],不是最大值的概率为(sz[i]- ...
- JS实现——贪吃蛇
把以下代码保存成Snake.html文件,使用Google或360浏览器打开 <!DOCTYPE HTML> <html> <head> <meta char ...
- html 标签附加文本属性
<!DOCTYPE html> <html> <head> <script> function showDetails(animal) { var an ...
- Educational Codeforces Round 11——C. Hard Process(YY)
C. Hard Process time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- BZOJ 4816 [Sdoi2017]数字表格 ——莫比乌斯反演
大力反演出奇迹. 然后xjb维护. 毕竟T1 #include <map> #include <ctime> #include <cmath> #include & ...