Submission #276016

# Submission time Handle Problem Language Result Execution time Memory
276016 2020-08-20T09:42:57 Z islingr Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
119 ms 10872 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b); i-- > (a); )

const int N = 1 << 18;
pair<int, int> a[N];
int b[N], c[N], p[N], s[N];

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

	int n; cin >> n;
	rep(i, 0, n + 1) {
		int x; cin >> x;
		a[i] = {x, i};
	}
	rep(i, 0, n) cin >> b[i];
	sort(a, a + n + 1); sort(b, b + n);
	rep(i, 0, n) p[i + 1] = max(p[i], a[i].first - b[i]);
	per(i, 0, n) s[i] = max(s[i + 1], a[i + 1].first - b[i]);
	rep(i, 0, n + 1) c[a[i].second] = max(p[i], s[i]);
	rep(i, 0, n + 1) cout << c[i] << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 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 1 ms 384 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 1 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 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 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 1 ms 384 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 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 1 ms 508 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 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 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 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 1 ms 384 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 512 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 1 ms 512 KB Output is correct
19 Correct 1 ms 512 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 2 ms 512 KB Output is correct
23 Correct 1 ms 508 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 2 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 512 KB Output is correct
33 Correct 98 ms 10104 KB Output is correct
34 Correct 104 ms 10496 KB Output is correct
35 Correct 112 ms 10104 KB Output is correct
36 Correct 100 ms 10616 KB Output is correct
37 Correct 103 ms 10872 KB Output is correct
38 Correct 119 ms 10744 KB Output is correct
39 Correct 115 ms 9848 KB Output is correct
40 Correct 99 ms 9828 KB Output is correct
41 Correct 105 ms 9976 KB Output is correct
42 Correct 102 ms 9936 KB Output is correct
43 Correct 98 ms 9848 KB Output is correct
44 Correct 96 ms 9464 KB Output is correct
45 Correct 104 ms 9468 KB Output is correct
46 Correct 107 ms 9464 KB Output is correct
47 Correct 114 ms 9464 KB Output is correct
48 Correct 105 ms 9592 KB Output is correct
49 Correct 108 ms 10104 KB Output is correct
50 Correct 116 ms 10104 KB Output is correct
51 Correct 102 ms 10232 KB Output is correct
52 Correct 102 ms 10104 KB Output is correct
53 Correct 103 ms 10108 KB Output is correct