Submission #955227

# Submission time Handle Problem Language Result Execution time Memory
955227 2024-03-29T20:21:52 Z Dennis_Jason Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
174 ms 15440 KB
#include <bits/stdc++.h>
#define NMAX 200001
#define pb push_back
#define MOD 1000000007
#define nl '\n'
#define INF 0x3f3f3f3f
#define int long long
using namespace std;

int n,a[NMAX],c[NMAX],st[NMAX],dr[NMAX];
struct arr{
    int x,poz;
    bool operator <(const arr &c) const{
        return x<c.x;
    }
}b[NMAX];
signed main() {

   cin>>n;
   for(int i=1;i<=n+1;++i)
   {
       cin>>b[i].x;
       b[i].poz=i;
   }
   sort(b+1,b+1+n+1);
   for(int i=1;i<=n;++i)
   {
       cin>>a[i];
   }
   sort(a+1,a+1+n);
   for(int i=1;i<=n;++i)
   {
       st[i]=b[i].x-a[i];
       st[i]=max(st[i],st[i-1]);
   }
   for(int i=n;i>=1;--i)
   {
       dr[i]=b[i+1].x-a[i];
       dr[i]=max(dr[i],dr[i+1]);
   }
   for(int i=1;i<=n+1;++i)
   {
       int aux=dr[i];
       aux=max(aux,st[i-1]);
       c[b[i].poz]=aux;
   }
   for(int i=1;i<=n+1;++i)
       cout<<c[i]<<" ";





    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2548 KB Output is correct
8 Correct 2 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2548 KB Output is correct
8 Correct 2 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2648 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 3 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 2 ms 2548 KB Output is correct
24 Correct 2 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 3 ms 2548 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2548 KB Output is correct
8 Correct 2 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 2 ms 2648 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 3 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 2 ms 2548 KB Output is correct
24 Correct 2 ms 2396 KB Output is correct
25 Correct 2 ms 2396 KB Output is correct
26 Correct 3 ms 2548 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 2 ms 2396 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2560 KB Output is correct
33 Correct 146 ms 14792 KB Output is correct
34 Correct 174 ms 15176 KB Output is correct
35 Correct 144 ms 14676 KB Output is correct
36 Correct 152 ms 15168 KB Output is correct
37 Correct 149 ms 15440 KB Output is correct
38 Correct 148 ms 15440 KB Output is correct
39 Correct 146 ms 14416 KB Output is correct
40 Correct 143 ms 14420 KB Output is correct
41 Correct 146 ms 14536 KB Output is correct
42 Correct 149 ms 14536 KB Output is correct
43 Correct 144 ms 14416 KB Output is correct
44 Correct 141 ms 14036 KB Output is correct
45 Correct 151 ms 14032 KB Output is correct
46 Correct 145 ms 14160 KB Output is correct
47 Correct 135 ms 14076 KB Output is correct
48 Correct 140 ms 14160 KB Output is correct
49 Correct 147 ms 14672 KB Output is correct
50 Correct 152 ms 14800 KB Output is correct
51 Correct 149 ms 14932 KB Output is correct
52 Correct 151 ms 14676 KB Output is correct
53 Correct 149 ms 14676 KB Output is correct