-
Notifications
You must be signed in to change notification settings - Fork 8
/
J144.cpp
48 lines (48 loc) · 855 Bytes
/
J144.cpp
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
#include <cstdio>
int x[200001];
int main() {
long long n, a, b;
scanf("%lld %lld %lld", &n, &a, &b);
for (int i = 1; i <= a; i++) {
x[i] = 1;
}
long long s = n * (n + 1) / 2;
long long sa = a * (a + 1) / 2;
long long t = s / 2;
for (int i = a, j = n; i > 0 && sa < t; i--, j--) {
if (t - sa >= b) {
sa += b;
x[i] = 0;
x[j] = 1;
} else {
x[i] = 0;
x[i + t - sa] = 1;
break;
}
}
bool space = false;
for (int i = 1; i <= n; i++) {
if (x[i] == 0) {
continue;
}
if (space) {
printf(" ");
}
printf("%d", i);
space = true;
}
printf("\n");
space = false;
for (int i = 1; i <= n; i++) {
if (x[i] == 1) {
continue;
}
if (space) {
printf(" ");
}
printf("%d", i);
space = true;
}
printf("\n");
return 0;
}