Submission #307634

# Submission time Handle Problem Language Result Execution time Memory
307634 2020-09-28T21:25:22 Z Temmie Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
107 ms 9336 KB
#include <bits/stdc++.h>

int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	int n; std::cin >> n;
	std::vector <int> b(n), ans(n + 1);
	std::vector <std::pair <int, int>> a(n + 1);
	for (int i = 0; i <= n; i++) std::cin >> a[i].first, a[i].second = i;
	for (int& x : b) std::cin >> x;
	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end());
	for (int i = 0, max = 0; i < n; i++) {
		max = std::max(max, a[i].first - b[i]);
		ans[a[i + 1].second] = std::max(ans[a[i + 1].second], max);
	}
	for (int i = n, max = 0; i > 0; i--) {
		max = std::max(max, a[i].first - b[i - 1]);
		ans[a[i - 1].second] = std::max(ans[a[i - 1].second], max);
	}
	for (int i = 0; i <= n; i++) std::cout << ans[i] << " \n"[i == n];
	
}
# Verdict Execution time Memory 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 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 360 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory 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 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 360 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 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory 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 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 360 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 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 512 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 97 ms 8624 KB Output is correct
34 Correct 107 ms 8872 KB Output is correct
35 Correct 98 ms 8568 KB Output is correct
36 Correct 100 ms 9080 KB Output is correct
37 Correct 104 ms 9336 KB Output is correct
38 Correct 103 ms 9208 KB Output is correct
39 Correct 98 ms 8312 KB Output is correct
40 Correct 99 ms 8312 KB Output is correct
41 Correct 103 ms 8568 KB Output is correct
42 Correct 100 ms 8376 KB Output is correct
43 Correct 98 ms 8312 KB Output is correct
44 Correct 97 ms 7928 KB Output is correct
45 Correct 99 ms 7928 KB Output is correct
46 Correct 97 ms 7928 KB Output is correct
47 Correct 93 ms 7928 KB Output is correct
48 Correct 93 ms 8056 KB Output is correct
49 Correct 105 ms 8568 KB Output is correct
50 Correct 102 ms 8568 KB Output is correct
51 Correct 103 ms 8568 KB Output is correct
52 Correct 104 ms 8568 KB Output is correct
53 Correct 102 ms 8568 KB Output is correct