#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a), end(a)
const int N = 2e5 + 5;
int n, b[N], it[N << 2], ans[N];
ii a[N];
void upd(int i, int l, int r, int pos, int val) {
if (pos < l || pos > r) return;
if (l == r) {
it[i] = val;
return;
}
int m = (l + r) / 2;
upd(i << 1, l, m, pos, val);
upd(i << 1 | 1, m + 1, r, pos, val);
it[i] = max(it[i << 1], it[i << 1 | 1]);
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#define task "neckti"
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n + 1; ++i) {
cin >> a[i].fi;
a[i].se = i;
}
for (int i = 1; i <= n; ++i)
cin >> b[i];
sort(a + 1, a + n + 2);
sort(b + 1, b + n + 1);
for (int i = 1; i <= n; ++i)
upd(1, 1, n, i, a[i + 1].fi - b[i]);
for (int i = 1; i <= n + 1; ++i) {
ans[a[i].se] = it[1];
upd(1, 1, n, i, a[i].fi - b[i]);
}
for (int i = 1; i <= n + 1; ++i)
cout << ans[i] << ' ';
}
Compilation message
ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
35 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
36 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
2 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
2 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
186 ms |
6920 KB |
Output is correct |
34 |
Correct |
194 ms |
7160 KB |
Output is correct |
35 |
Correct |
184 ms |
6904 KB |
Output is correct |
36 |
Correct |
189 ms |
7416 KB |
Output is correct |
37 |
Correct |
195 ms |
7552 KB |
Output is correct |
38 |
Correct |
195 ms |
7520 KB |
Output is correct |
39 |
Correct |
186 ms |
6648 KB |
Output is correct |
40 |
Correct |
188 ms |
6520 KB |
Output is correct |
41 |
Correct |
190 ms |
6648 KB |
Output is correct |
42 |
Correct |
186 ms |
6648 KB |
Output is correct |
43 |
Correct |
190 ms |
6648 KB |
Output is correct |
44 |
Correct |
182 ms |
6268 KB |
Output is correct |
45 |
Correct |
183 ms |
6264 KB |
Output is correct |
46 |
Correct |
181 ms |
6268 KB |
Output is correct |
47 |
Correct |
179 ms |
6072 KB |
Output is correct |
48 |
Correct |
181 ms |
6136 KB |
Output is correct |
49 |
Correct |
195 ms |
6648 KB |
Output is correct |
50 |
Correct |
193 ms |
6648 KB |
Output is correct |
51 |
Correct |
194 ms |
6776 KB |
Output is correct |
52 |
Correct |
190 ms |
6648 KB |
Output is correct |
53 |
Correct |
192 ms |
6648 KB |
Output is correct |