# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
561865 | 2022-05-13T16:50:45 Z | dattranxxx | Just Long Neckties (JOI20_ho_t1) | C++11 | 109 ms | 6220 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long; void file() { const string FILE_NAME = "FILE_NAME"; freopen((FILE_NAME + ".inp").c_str(), "r", stdin); freopen((FILE_NAME + ".out").c_str(), "w", stdout); } const int N = 2e5 + 5; int a[N], pre[N], C[N]; pair<int, int> b[N]; int n; int main() { cin.tie(0)->sync_with_stdio(0); cout.tie(0); cin >> n; for (int i = 1; i <= n + 1; ++i) cin >> b[i].first, b[i].second = i; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); sort(b + 1, b + n + 2); for (int i = 1; i <= n; ++i) pre[i] = max(pre[i-1], b[i].first - a[i]); C[b[n+1].second] = pre[n]; int cur_max = 0; for (int i = n; i; --i) { // thay ai bang ai+1 cur_max = max(cur_max, b[i+1].first - a[i]); C[b[i].second] = max(pre[i-1], cur_max); } for (int i = 1; i <= n+1; ++i) cout << C[i] << ' '; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 356 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 356 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 87 ms | 5516 KB | Output is correct |
34 | Correct | 95 ms | 5716 KB | Output is correct |
35 | Correct | 87 ms | 5576 KB | Output is correct |
36 | Correct | 88 ms | 5944 KB | Output is correct |
37 | Correct | 92 ms | 6220 KB | Output is correct |
38 | Correct | 84 ms | 6096 KB | Output is correct |
39 | Correct | 87 ms | 5280 KB | Output is correct |
40 | Correct | 95 ms | 5148 KB | Output is correct |
41 | Correct | 84 ms | 5304 KB | Output is correct |
42 | Correct | 85 ms | 5180 KB | Output is correct |
43 | Correct | 89 ms | 5148 KB | Output is correct |
44 | Correct | 83 ms | 4856 KB | Output is correct |
45 | Correct | 83 ms | 4940 KB | Output is correct |
46 | Correct | 100 ms | 4940 KB | Output is correct |
47 | Correct | 94 ms | 4700 KB | Output is correct |
48 | Correct | 78 ms | 4764 KB | Output is correct |
49 | Correct | 84 ms | 5340 KB | Output is correct |
50 | Correct | 86 ms | 5340 KB | Output is correct |
51 | Correct | 109 ms | 5372 KB | Output is correct |
52 | Correct | 85 ms | 5324 KB | Output is correct |
53 | Correct | 88 ms | 5348 KB | Output is correct |