# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
635624 | 2022-08-26T14:00:26 Z | aris12345678 | Just Long Neckties (JOI20_ho_t1) | C++14 | 115 ms | 11064 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; #define X first #define Y second int main() { int n; scanf("%d", &n); vector<pii> a(n+1); vector<int> b(n); for(int i = 0; i <= n; i++) { scanf("%d", &a[i].X); a[i].Y = i; } for(int i = 0; i < n; i++) scanf("%d", &b[i]); sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<int> pref; pref.push_back(max(a[0].X-b[0], 0)); for(int i = 1; i < n; i++) pref.push_back(max(pref.back(), a[i].X-b[i])); // for(int i = 0; i < n; i++) // printf("%d ", pref[i]); // printf("\n"); vector<int> suf; suf.push_back(max(a[n].X-b[n-1], 0)); for(int i = n-2; i >= 0; i--) suf.push_back(max(suf.back(), a[i+1].X-b[i])); reverse(suf.begin(), suf.end()); // for(int i = 0; i < n; i++) // printf("%d ", suf[i]); // printf("\n"); vector<int> ans(n+1); for(int i = 0; i <= n; i++) { if(i == 0) ans[a[i].Y] = suf[i]; else if(i == n) ans[a[i].Y] = pref[i-1]; else { ans[a[i].Y] = max(pref[i-1], suf[i]); // cout << a[i].Y << " " << pref[i-1] << " " << suf[i] << "\n"; } } for(int i = 0; i <= n; i++) printf("%d ", ans[i]); printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 300 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 300 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 308 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 | 316 KB | Output is correct |
25 | Correct | 2 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 340 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 300 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 308 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 | 316 KB | Output is correct |
25 | Correct | 2 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 312 KB | Output is correct |
30 | Correct | 1 ms | 340 KB | Output is correct |
31 | Correct | 2 ms | 340 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
33 | Correct | 99 ms | 10056 KB | Output is correct |
34 | Correct | 92 ms | 10424 KB | Output is correct |
35 | Correct | 107 ms | 10092 KB | Output is correct |
36 | Correct | 89 ms | 10596 KB | Output is correct |
37 | Correct | 101 ms | 11064 KB | Output is correct |
38 | Correct | 115 ms | 10780 KB | Output is correct |
39 | Correct | 92 ms | 9860 KB | Output is correct |
40 | Correct | 89 ms | 9852 KB | Output is correct |
41 | Correct | 92 ms | 9968 KB | Output is correct |
42 | Correct | 92 ms | 9868 KB | Output is correct |
43 | Correct | 95 ms | 9988 KB | Output is correct |
44 | Correct | 86 ms | 9412 KB | Output is correct |
45 | Correct | 87 ms | 9496 KB | Output is correct |
46 | Correct | 90 ms | 9384 KB | Output is correct |
47 | Correct | 84 ms | 9532 KB | Output is correct |
48 | Correct | 89 ms | 9540 KB | Output is correct |
49 | Correct | 90 ms | 10088 KB | Output is correct |
50 | Correct | 95 ms | 10176 KB | Output is correct |
51 | Correct | 98 ms | 10180 KB | Output is correct |
52 | Correct | 89 ms | 10180 KB | Output is correct |
53 | Correct | 94 ms | 10124 KB | Output is correct |