Submission #1036785

# Submission time Handle Problem Language Result Execution time Memory
1036785 2024-07-27T17:07:46 Z andrewp Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
77 ms 10836 KB
//Dedicated to my love, ivaziva
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using ll = int64_t;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define dbg(x) cerr << #x << ": " << x << '\n';

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	int n;
	cin >> n;
	vector<pii> a(n + 1);
	vector<int> b(n), ans(n + 1);
	for (int i = 0; i <= n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(all(a));
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	sort(all(b));
	vector<int> ss(n + 2, 0), ps(n + 2, 0);
	ss[n] = max(a[n].first - b[n - 1], 0);
	for (int i = n - 1; i >= 0; i--) {
		ss[i] = max(ss[i + 1], max(a[i].first - b[i - 1], 0));
	}
	for (int i = 0; i <= n; i++) {
		if (i != n) {
			ps[i + 1] = max(ps[i], max(a[i].first - b[i], 0));
		}
	}
	for (int i = 0; i <= n; i++) {
		ans[a[i].second] = max(ps[i], ss[i + 1]);
	}
	for (int i = 0; i <= n; i++) cout << ans[i] << ' ';
	cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 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 1 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 348 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 348 KB Output is correct
18 Correct 1 ms 508 KB Output is correct
19 Correct 1 ms 348 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 348 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 348 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 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 348 KB Output is correct
18 Correct 1 ms 508 KB Output is correct
19 Correct 1 ms 348 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 348 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 348 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 61 ms 10068 KB Output is correct
34 Correct 67 ms 10344 KB Output is correct
35 Correct 61 ms 10064 KB Output is correct
36 Correct 63 ms 10548 KB Output is correct
37 Correct 65 ms 10836 KB Output is correct
38 Correct 65 ms 10836 KB Output is correct
39 Correct 77 ms 9812 KB Output is correct
40 Correct 68 ms 9676 KB Output is correct
41 Correct 63 ms 9872 KB Output is correct
42 Correct 64 ms 9812 KB Output is correct
43 Correct 61 ms 9812 KB Output is correct
44 Correct 60 ms 9320 KB Output is correct
45 Correct 61 ms 9356 KB Output is correct
46 Correct 68 ms 9576 KB Output is correct
47 Correct 59 ms 9556 KB Output is correct
48 Correct 57 ms 9604 KB Output is correct
49 Correct 65 ms 10116 KB Output is correct
50 Correct 64 ms 10068 KB Output is correct
51 Correct 69 ms 10108 KB Output is correct
52 Correct 64 ms 10068 KB Output is correct
53 Correct 65 ms 9972 KB Output is correct