Submission #443205

# Submission time Handle Problem Language Result Execution time Memory
443205 2021-07-10T07:16:40 Z Fidisk Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
136 ms 18612 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e15
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) (((xxxx)>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<pair<int,int>,pair<int,int>> piiii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
typedef pair<pair<long long,long long>,pair<long long,long long>> pllll;
typedef pair<pair<long long,long long>,bool> pllb;
typedef pair<long double,long double> pld;
typedef pair<pair<long double,long double>,long double> plld;

const ll base=2e9+4257;
//const ll mod=1e9+7;
const ll mod2=1e9+4233;
const ld eps=1e-12;
const ll maxn=1e16;
const ld pi=acos(-1);
const ll delta=1e5+7;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};

ll n,i,ans[500009],f[500009],f2[500009],pre[500009],suf[500009],b[500009];
pll a[500009];

int main(){
    IO;
    cin>>n;
    for (i=1;i<=n+1;i++) {
        cin>>a[i].fi;
        a[i].se=i;
    }
    for (i=1;i<=n;i++) {
        cin>>b[i];
    }
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    for (i=1;i<=n;i++) {
        f[i]=a[i].fi-b[i];
        f2[i]=a[i+1].fi-b[i];
    }
    for (i=1;i<=n;i++) {
        pre[i]=max(pre[i-1],f[i]);
    }
    for (i=n;i>=1;i--) {
        suf[i]=max(suf[i+1],f2[i]);
    }
    for (i=1;i<=n+1;i++) {
        ans[a[i].se]=max(pre[i-1],suf[i]);
    }
    for (i=1;i<=n+1;i++) {
        cout<<ans[i]<<' ';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 524 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 524 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 456 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 107 ms 17384 KB Output is correct
34 Correct 136 ms 18208 KB Output is correct
35 Correct 110 ms 17540 KB Output is correct
36 Correct 109 ms 18116 KB Output is correct
37 Correct 112 ms 18612 KB Output is correct
38 Correct 112 ms 18432 KB Output is correct
39 Correct 115 ms 17384 KB Output is correct
40 Correct 110 ms 17260 KB Output is correct
41 Correct 108 ms 17516 KB Output is correct
42 Correct 122 ms 17688 KB Output is correct
43 Correct 109 ms 17356 KB Output is correct
44 Correct 109 ms 16836 KB Output is correct
45 Correct 108 ms 16980 KB Output is correct
46 Correct 109 ms 16836 KB Output is correct
47 Correct 102 ms 17252 KB Output is correct
48 Correct 103 ms 17336 KB Output is correct
49 Correct 109 ms 17836 KB Output is correct
50 Correct 118 ms 17924 KB Output is correct
51 Correct 112 ms 17860 KB Output is correct
52 Correct 115 ms 17864 KB Output is correct
53 Correct 122 ms 17856 KB Output is correct