Submission #387925

# Submission time Handle Problem Language Result Execution time Memory
387925 2021-04-09T13:48:20 Z nikatamliani Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
124 ms 14748 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 5e5+5, oo = 1e18+10;
ll a[N], b[N], ans[N], p[N], s[N], n;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n+1; ++i) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; ++i) {
		cin >> b[i];
	}
	vector<int> ids(n+1);
	iota(ids.begin(), ids.end(), 1);
	sort(ids.begin(), ids.end(), [&](int x, int y) {
		return a[x] < a[y];
	});
	sort(b+1, b+n+1);
	for(int i = 1; i <= n+1; ++i) {
		p[i] = max(p[i-1], a[ids[i - 1]] - b[i]);
	}
	for(int i = n+1; i >= 1; --i) {
		s[i] = max(s[i+1], a[ids[i - 1]] - b[i - 1]);
	}
	for(int i = 1; i <= n+1; ++i) {
		ans[ids[i - 1]] = max(p[i-1], s[i+1]);
	}
	for(int i = 1; i <= n+1; ++i) {
		cout << ans[i] << ' ';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 122 ms 13764 KB Output is correct
34 Correct 113 ms 14216 KB Output is correct
35 Correct 124 ms 13836 KB Output is correct
36 Correct 111 ms 14264 KB Output is correct
37 Correct 114 ms 14748 KB Output is correct
38 Correct 112 ms 14532 KB Output is correct
39 Correct 115 ms 13592 KB Output is correct
40 Correct 107 ms 13512 KB Output is correct
41 Correct 109 ms 13804 KB Output is correct
42 Correct 109 ms 13636 KB Output is correct
43 Correct 108 ms 13508 KB Output is correct
44 Correct 107 ms 13104 KB Output is correct
45 Correct 113 ms 13160 KB Output is correct
46 Correct 107 ms 13208 KB Output is correct
47 Correct 87 ms 13392 KB Output is correct
48 Correct 96 ms 13340 KB Output is correct
49 Correct 111 ms 13972 KB Output is correct
50 Correct 113 ms 14016 KB Output is correct
51 Correct 109 ms 14016 KB Output is correct
52 Correct 113 ms 14032 KB Output is correct
53 Correct 112 ms 14020 KB Output is correct