Submission #330290

# Submission time Handle Problem Language Result Execution time Memory
330290 2020-11-24T13:58:43 Z a_player Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
265 ms 11628 KB
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

const int nax=2e5+5;
int n;
pair <int,int> a[nax],b[nax];
int c[nax];
int pre[nax],succ[nax];
int main(){
  cin>>n;
  for(int i=0;i<n+1;i++)cin>>a[i].f,a[i].s=i;
  for(int i=0;i<n;i++)cin>>b[i].f,b[i].s=i;
  sort(a,a+n+1);
  sort(b,b+n);
  pre[0]=max(0,a[0].f-b[0].f);
  for(int i=1;i<n;i++)pre[i]=max(pre[i-1],max(0,a[i].f-b[i].f));
  succ[n-1]=max(0,a[n].f-b[n-1].f);
  for(int i=n-2;i>=0;i--)succ[i]=max(succ[i+1],max(0,a[i+1].f-b[i].f));
  for(int i=0;i<n+1;i++){
    if(i==0)c[a[i].s]=succ[i];
    else if(i==n)c[a[i].s]=pre[i-1];
    else c[a[i].s]=max(succ[i],pre[i-1]);
  }
  for(int i=0;i<n+1;i++)cout<<c[i]<<" ";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 3 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 3 ms 492 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 3 ms 492 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 492 KB Output is correct
25 Correct 3 ms 492 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 492 KB Output is correct
28 Correct 2 ms 492 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 3 ms 492 KB Output is correct
32 Correct 3 ms 492 KB Output is correct
33 Correct 224 ms 10860 KB Output is correct
34 Correct 235 ms 11244 KB Output is correct
35 Correct 223 ms 10860 KB Output is correct
36 Correct 237 ms 11372 KB Output is correct
37 Correct 236 ms 11628 KB Output is correct
38 Correct 231 ms 11500 KB Output is correct
39 Correct 236 ms 10604 KB Output is correct
40 Correct 223 ms 10604 KB Output is correct
41 Correct 245 ms 10988 KB Output is correct
42 Correct 226 ms 10604 KB Output is correct
43 Correct 255 ms 10604 KB Output is correct
44 Correct 228 ms 10092 KB Output is correct
45 Correct 234 ms 10220 KB Output is correct
46 Correct 223 ms 10092 KB Output is correct
47 Correct 232 ms 10348 KB Output is correct
48 Correct 265 ms 10348 KB Output is correct
49 Correct 233 ms 10860 KB Output is correct
50 Correct 235 ms 10860 KB Output is correct
51 Correct 234 ms 10860 KB Output is correct
52 Correct 232 ms 10860 KB Output is correct
53 Correct 234 ms 10860 KB Output is correct