답안 #330569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330569 2020-11-25T18:48:30 Z Sho10 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
119 ms 15596 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod (10*10*10*10*10*10*10*10*10+7)
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,b[200005],pref[200005],suf[200005],ans[200005];
pair<ll,ll>a[200005];
int32_t main(){
CODE_START;
cin>>n;
for(ll i=1;i<=n+1;i++)
{
    cin>>a[i].f;
    a[i].s=i;
}
for(ll i=1;i<=n;i++)
{
    cin>>b[i];
}
sort(a+1,a+n+2);
sort(b+1,b+n+1);
for(ll i=1;i<=n+1;i++)
{
    pref[i]=max(pref[i-1],a[i].f-b[i]);
}
for(ll i=n+1;i>=2;i--)
{
    suf[i]=max(suf[i+1],a[i].f-b[i-1]);
}
for(ll i=1;i<=n+1;i++)
{
    ans[a[i].s]=max(pref[i-1],suf[i+1]);
}
for(ll i=1;i<=n+1;i++)
{
    cout<<ans[i]<<' ';
}
}



# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 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 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 2 ms 632 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 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 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 2 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 2 ms 632 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 2 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 102 ms 14572 KB Output is correct
34 Correct 106 ms 15212 KB Output is correct
35 Correct 102 ms 14572 KB Output is correct
36 Correct 103 ms 15084 KB Output is correct
37 Correct 111 ms 15596 KB Output is correct
38 Correct 119 ms 15468 KB Output is correct
39 Correct 102 ms 14444 KB Output is correct
40 Correct 103 ms 14316 KB Output is correct
41 Correct 114 ms 14572 KB Output is correct
42 Correct 101 ms 14444 KB Output is correct
43 Correct 101 ms 14316 KB Output is correct
44 Correct 100 ms 13932 KB Output is correct
45 Correct 101 ms 14060 KB Output is correct
46 Correct 102 ms 13960 KB Output is correct
47 Correct 106 ms 14188 KB Output is correct
48 Correct 106 ms 14316 KB Output is correct
49 Correct 105 ms 14828 KB Output is correct
50 Correct 106 ms 14956 KB Output is correct
51 Correct 104 ms 14828 KB Output is correct
52 Correct 104 ms 14828 KB Output is correct
53 Correct 104 ms 14828 KB Output is correct