# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224014 | 2020-04-17T04:46:02 Z | tqbfjotld | Just Long Neckties (JOI20_ho_t1) | C++14 | 135 ms | 8292 KB |
#include <bits/stdc++.h> using namespace std; int ans[200005]; vector<pair<int,int> > a; vector<int> b; int n; int pre[200005]; int suf[200005]; int main(){ scanf("%d",&n); for (int x = 0; x<n+1; x++){ int c; scanf("%d",&c); a.push_back({c,x}); } for (int x = 0; x<n; x++){ int c; scanf("%d",&c); b.push_back(c); } sort(a.begin(),a.end()); sort(b.begin(),b.end()); int t = 0; for (int x = 0; x<n; x++){ t = max(t,a[x].first-b[x]); pre[x] = t; } t = 0; for (int x = n-1; x>=0; x--){ t = max(t,a[x+1].first-b[x]); suf[x] = t; } for (int x = 0; x<=n; x++){ if (x==0) ans[a[x].second] = suf[0]; else if (x==n) ans[a[x].second] = pre[x-1]; else ans[a[x].second] = max(pre[x-1],suf[x]); } for (int x = 0; x<=n; x++){ printf("%d ",ans[x]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 6 ms | 512 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 6 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 6 ms | 384 KB | Output is correct |
26 | Correct | 7 ms | 384 KB | Output is correct |
27 | Correct | 6 ms | 384 KB | Output is correct |
28 | Correct | 6 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 6 ms | 384 KB | Output is correct |
31 | Correct | 6 ms | 384 KB | Output is correct |
32 | Correct | 6 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 4 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 4 ms | 384 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 6 ms | 512 KB | Output is correct |
18 | Correct | 6 ms | 384 KB | Output is correct |
19 | Correct | 6 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 5 ms | 384 KB | Output is correct |
23 | Correct | 6 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 6 ms | 384 KB | Output is correct |
26 | Correct | 7 ms | 384 KB | Output is correct |
27 | Correct | 6 ms | 384 KB | Output is correct |
28 | Correct | 6 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 6 ms | 384 KB | Output is correct |
31 | Correct | 6 ms | 384 KB | Output is correct |
32 | Correct | 6 ms | 512 KB | Output is correct |
33 | Correct | 125 ms | 7784 KB | Output is correct |
34 | Correct | 130 ms | 7908 KB | Output is correct |
35 | Correct | 133 ms | 7652 KB | Output is correct |
36 | Correct | 126 ms | 8036 KB | Output is correct |
37 | Correct | 135 ms | 8292 KB | Output is correct |
38 | Correct | 132 ms | 8164 KB | Output is correct |
39 | Correct | 130 ms | 7396 KB | Output is correct |
40 | Correct | 133 ms | 7396 KB | Output is correct |
41 | Correct | 131 ms | 7400 KB | Output is correct |
42 | Correct | 130 ms | 7524 KB | Output is correct |
43 | Correct | 127 ms | 7268 KB | Output is correct |
44 | Correct | 125 ms | 6984 KB | Output is correct |
45 | Correct | 126 ms | 7012 KB | Output is correct |
46 | Correct | 125 ms | 7140 KB | Output is correct |
47 | Correct | 110 ms | 6884 KB | Output is correct |
48 | Correct | 112 ms | 6884 KB | Output is correct |
49 | Correct | 130 ms | 7524 KB | Output is correct |
50 | Correct | 133 ms | 7524 KB | Output is correct |
51 | Correct | 134 ms | 7528 KB | Output is correct |
52 | Correct | 132 ms | 7496 KB | Output is correct |
53 | Correct | 133 ms | 7524 KB | Output is correct |