Submission #1031718

# Submission time Handle Problem Language Result Execution time Memory
1031718 2024-07-23T05:24:07 Z juicy Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
76 ms 10868 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;

int n;
int b[N], pf[N], sf[N], res[N];
array<int, 2> a[N];

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	cin >> n;
	for (int i = 1; i <= n + 1; ++i) {
		cin >> a[i][0];
		a[i][1] = 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) {
		pf[i] = max(pf[i - 1], max(0, a[i][0] - b[i]));
	}
	for (int i = n + 1; i >= 2; --i) {
		sf[i] = max(sf[i + 1], max(0, a[i][0] - b[i - 1]));
	}
	for (int i = 1; i <= n + 1; ++i) {
		res[a[i][1]] = max(pf[i - 1], sf[i + 1]);
	}
	for (int i = 1; i <= n + 1; ++i) {
		cout << res[i] << " ";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 524 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 516 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 512 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 524 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 516 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 484 KB Output is correct
33 Correct 63 ms 9956 KB Output is correct
34 Correct 66 ms 10552 KB Output is correct
35 Correct 68 ms 10068 KB Output is correct
36 Correct 76 ms 10580 KB Output is correct
37 Correct 67 ms 10868 KB Output is correct
38 Correct 66 ms 10708 KB Output is correct
39 Correct 64 ms 9784 KB Output is correct
40 Correct 66 ms 9812 KB Output is correct
41 Correct 65 ms 9868 KB Output is correct
42 Correct 66 ms 9944 KB Output is correct
43 Correct 64 ms 9804 KB Output is correct
44 Correct 66 ms 9436 KB Output is correct
45 Correct 63 ms 9552 KB Output is correct
46 Correct 63 ms 9300 KB Output is correct
47 Correct 61 ms 9556 KB Output is correct
48 Correct 60 ms 9556 KB Output is correct
49 Correct 69 ms 9972 KB Output is correct
50 Correct 68 ms 10068 KB Output is correct
51 Correct 65 ms 10064 KB Output is correct
52 Correct 65 ms 10008 KB Output is correct
53 Correct 67 ms 10064 KB Output is correct