# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566740 | 2022-05-22T19:21:01 Z | milisav | Just Long Neckties (JOI20_ho_t1) | C++14 | 120 ms | 11640 KB |
#include<bits/stdc++.h> #define maxn 500000 using namespace std; int n; int a[maxn]; int b[maxn]; pair<int,int> ordr[maxn]; int ans[maxn]; int pref[maxn]; int suf[maxn]; int main() { scanf("%d",&n); for(int i=1;i<=n+1;i++) { scanf("%d",&a[i]); ordr[i]={a[i],i}; } for(int i=1;i<=n;i++) scanf("%d",&b[i]); sort(a+1,a+(n+2)); sort(ordr+1,ordr+(n+2)); sort(b+1,b+(n+1)); for(int i=1;i<=n;i++) pref[i]=max(pref[i-1],max(a[i]-b[i],0)); for(int i=n;i>=1;i--) suf[i]=max(suf[i+1],max(a[i+1]-b[i],0)); for(int i=1;i<=n+1;i++) { ans[ordr[i].second] = max(pref[i-1],suf[i]); } for(int i=1;i<=n+1;i++) { printf("%d ",ans[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 312 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 312 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 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 | 320 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 2 ms | 340 KB | Output is correct |
19 | Correct | 2 ms | 340 KB | Output is correct |
20 | Correct | 2 ms | 364 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 | 2 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 320 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 320 KB | Output is correct |
31 | Correct | 2 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 312 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 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 | 320 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 2 ms | 340 KB | Output is correct |
19 | Correct | 2 ms | 340 KB | Output is correct |
20 | Correct | 2 ms | 364 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 | 2 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 320 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 320 KB | Output is correct |
31 | Correct | 2 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 468 KB | Output is correct |
33 | Correct | 100 ms | 10644 KB | Output is correct |
34 | Correct | 106 ms | 11228 KB | Output is correct |
35 | Correct | 106 ms | 10744 KB | Output is correct |
36 | Correct | 120 ms | 11212 KB | Output is correct |
37 | Correct | 105 ms | 11640 KB | Output is correct |
38 | Correct | 112 ms | 11432 KB | Output is correct |
39 | Correct | 116 ms | 10524 KB | Output is correct |
40 | Correct | 108 ms | 10420 KB | Output is correct |
41 | Correct | 100 ms | 10580 KB | Output is correct |
42 | Correct | 101 ms | 10584 KB | Output is correct |
43 | Correct | 119 ms | 10420 KB | Output is correct |
44 | Correct | 114 ms | 10044 KB | Output is correct |
45 | Correct | 102 ms | 10188 KB | Output is correct |
46 | Correct | 100 ms | 10096 KB | Output is correct |
47 | Correct | 110 ms | 10172 KB | Output is correct |
48 | Correct | 93 ms | 10168 KB | Output is correct |
49 | Correct | 112 ms | 10900 KB | Output is correct |
50 | Correct | 117 ms | 10828 KB | Output is correct |
51 | Correct | 104 ms | 10848 KB | Output is correct |
52 | Correct | 119 ms | 10844 KB | Output is correct |
53 | Correct | 118 ms | 10824 KB | Output is correct |