forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path171.cpp
More file actions
79 lines (72 loc) · 1.23 KB
/
171.cpp
File metadata and controls
79 lines (72 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//ac
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define for if(0); else for
class zone {
public:
int num;
int q;
int idx;
bool operator<(const zone& rhs) const {
return q < rhs.q;
}
}zo[100];
class student {
public:
int q;
int w;
int idx;
bool operator<(const student& rhs) const {
return w > rhs.w;
}
}stu[16000];
int pos[16000];
int k, n;
int main() {
scanf("%d", &k);
n = 0;
for (int i = 0; i < k; ++i) {
scanf("%d", &zo[i].num);
zo[i].idx = i;
n += zo[i].num;
}
for (int i = 0; i < k; ++i) {
scanf("%d", &zo[i].q);
}
for (int i = 0; i < n; ++i) {
scanf("%d", &stu[i].q);
}
for (int i = 0; i < n; ++i) {
scanf("%d", &stu[i].w);
stu[i].idx = i;
}
sort(zo, zo + k);
sort(stu, stu + n);
for (int i = 0; i < n; ++i) {
int flag = 1;
for (int j = k - 1; j >= 0; --j) {
if (zo[j].num > 0 && zo[j].q < stu[i].q) {
pos[stu[i].idx] = zo[j].idx;
zo[j].num -= 1;
flag = 0;
break;
}
}
if (flag) {
for (int j = k - 1; j >= 0; --j) {
if (zo[j].num > 0) {
pos[stu[i].idx] = zo[j].idx;
zo[j].num -= 1;
break;
}
}
}
}
for (int i = 0; i < n; ++i) {
printf("%d ", pos[i] + 1);
}
printf("\n");
return 0;
}