# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
365214 | 2021-02-11T09:05:20 Z | jazzup | Just Long Neckties (JOI20_ho_t1) | C++14 | 166 ms | 10092 KB |
#include<cstdio> #include<algorithm> using namespace std; int a[200010],aa[200010],b[200010],dp1[200010],dp2[200010]; int main(){ int n; scanf("%d",&n); for(int i=0;i<=n;i++){ scanf("%d",&aa[i]); a[i]=aa[i]; } sort(a,a+n+1); for(int i=0;i<n;i++){ scanf("%d",&b[i]); } sort(b,b+n); dp1[0]=max(a[0]-b[0],0); for(int i=1;i<n;i++){ dp1[i]=max(dp1[i-1],max(a[i]-b[i],0)); } dp2[n-1]=max(a[n]-b[n-1],0); for(int i=n-2;i>=0;i--){ dp2[i]=max(dp2[i+1],max(a[i+1]-b[i],0)); } for(int i=0;i<=n;i++){ int *p=lower_bound(a,a+n+1,aa[i]); int x=p-a; printf("%d ",max(dp1[x-1],dp2[x])); } // for(int i=0;i<n;i++){ // printf("%d ",dp1[i]); // } // printf("\n"); // for(int i=0;i<n;i++){ // printf("%d ",dp2[i]); // } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 2 ms | 492 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 2 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 2 ms | 364 KB | Output is correct |
26 | Correct | 2 ms | 364 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
31 | Correct | 2 ms | 364 KB | Output is correct |
32 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 2 ms | 492 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 2 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 2 ms | 364 KB | Output is correct |
26 | Correct | 2 ms | 364 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
31 | Correct | 2 ms | 364 KB | Output is correct |
32 | Correct | 2 ms | 364 KB | Output is correct |
33 | Correct | 149 ms | 6892 KB | Output is correct |
34 | Correct | 155 ms | 9656 KB | Output is correct |
35 | Correct | 152 ms | 9324 KB | Output is correct |
36 | Correct | 157 ms | 9836 KB | Output is correct |
37 | Correct | 159 ms | 10092 KB | Output is correct |
38 | Correct | 158 ms | 9964 KB | Output is correct |
39 | Correct | 155 ms | 9068 KB | Output is correct |
40 | Correct | 154 ms | 9068 KB | Output is correct |
41 | Correct | 166 ms | 9068 KB | Output is correct |
42 | Correct | 154 ms | 9016 KB | Output is correct |
43 | Correct | 163 ms | 9068 KB | Output is correct |
44 | Correct | 154 ms | 8684 KB | Output is correct |
45 | Correct | 150 ms | 8684 KB | Output is correct |
46 | Correct | 153 ms | 8688 KB | Output is correct |
47 | Correct | 116 ms | 8744 KB | Output is correct |
48 | Correct | 127 ms | 8696 KB | Output is correct |
49 | Correct | 159 ms | 9452 KB | Output is correct |
50 | Correct | 163 ms | 9220 KB | Output is correct |
51 | Correct | 157 ms | 9444 KB | Output is correct |
52 | Correct | 158 ms | 9436 KB | Output is correct |
53 | Correct | 160 ms | 9324 KB | Output is correct |