#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("Ofast")
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define MEM(x, n) memset(x, n, sizeof(x))
#define pii pair<int, int>
#define pdd pair<double, double>
#define DB(x) cerr << #x << " " << x << endl;
#define endl "\n"
#define Koying ios::sync_wit_stdio(0), cin.tie(0)
#define lowbit(x) x &(-x)
#define F first
#define S second
const int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
#define MAXN 200005
int n;
int ans[MAXN];
pii x[MAXN], y[MAXN];
void sol() {
cin >> n;
for (int i = 0; i <= n; i++) {
cin >> x[i].F;
x[i].S = i;
}
for (int i = 0; i < n; i++) {
cin >> y[i].F;
y[i].S = i;
}
sort(x, x + n + 1);
sort(y, y + n);
multiset<int> s;
for (int i = 0; i < n; i++) {
s.insert(max(x[i].F - y[i].F, 0ll));
}
ans[x[n].S] = *--s.end();
for (int i = n - 1; i >= 0; i--) {
s.erase(s.find(max(x[i].F - y[i].F, 0ll)));
s.insert(max(x[i + 1].F - y[i].F, 0ll));
ans[x[i].S] = *--s.end();
}
for (int i = 0; i <= n; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
signed main()
{
int t = 1;
//cin >> t;
sol();
//system("pause");
return 0;
}
Compilation message
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:57:9: warning: unused variable 't' [-Wunused-variable]
57 | int t = 1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
496 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
396 KB |
Output is correct |
20 |
Correct |
4 ms |
456 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
4 ms |
468 KB |
Output is correct |
23 |
Correct |
3 ms |
468 KB |
Output is correct |
24 |
Correct |
3 ms |
468 KB |
Output is correct |
25 |
Correct |
3 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
448 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
496 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
3 ms |
396 KB |
Output is correct |
20 |
Correct |
4 ms |
456 KB |
Output is correct |
21 |
Correct |
3 ms |
468 KB |
Output is correct |
22 |
Correct |
4 ms |
468 KB |
Output is correct |
23 |
Correct |
3 ms |
468 KB |
Output is correct |
24 |
Correct |
3 ms |
468 KB |
Output is correct |
25 |
Correct |
3 ms |
468 KB |
Output is correct |
26 |
Correct |
3 ms |
448 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
3 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
3 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
468 KB |
Output is correct |
33 |
Correct |
277 ms |
21912 KB |
Output is correct |
34 |
Correct |
296 ms |
22704 KB |
Output is correct |
35 |
Correct |
279 ms |
22032 KB |
Output is correct |
36 |
Correct |
316 ms |
22600 KB |
Output is correct |
37 |
Correct |
307 ms |
23244 KB |
Output is correct |
38 |
Correct |
283 ms |
22972 KB |
Output is correct |
39 |
Correct |
375 ms |
21980 KB |
Output is correct |
40 |
Correct |
332 ms |
21792 KB |
Output is correct |
41 |
Correct |
356 ms |
22032 KB |
Output is correct |
42 |
Correct |
319 ms |
21964 KB |
Output is correct |
43 |
Correct |
348 ms |
21856 KB |
Output is correct |
44 |
Correct |
294 ms |
21148 KB |
Output is correct |
45 |
Correct |
309 ms |
21336 KB |
Output is correct |
46 |
Correct |
333 ms |
21312 KB |
Output is correct |
47 |
Correct |
275 ms |
21928 KB |
Output is correct |
48 |
Correct |
340 ms |
21964 KB |
Output is correct |
49 |
Correct |
322 ms |
22476 KB |
Output is correct |
50 |
Correct |
389 ms |
22528 KB |
Output is correct |
51 |
Correct |
353 ms |
22456 KB |
Output is correct |
52 |
Correct |
417 ms |
22524 KB |
Output is correct |
53 |
Correct |
438 ms |
22544 KB |
Output is correct |