답안 #848296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
848296 2023-09-12T03:01:38 Z dungz Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
77 ms 18772 KB
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i,a,b) for(ll i=a;i<=b;++i)
#define ff(i,a,b) for(ll i=a;i>=b;--i)
#define fi first
#define se second
#define endl '\n'
#define task "task"
#define task "task"
#define prll pair<ll,ll>
#define pb push_back
#define ld long double
const ll MIN=-1e18,MAX=1e18,MOD=1e9+7;
prll b[200005];
ll c[200005],mx1[200005],mx2[200005],h1[200005],h2[200005],ans[200005];
int main()
{
//	#ifndef ONLINE_JUDGE
//   		freopen (task".inp", "r", stdin);
//   		freopen (task".out", "w", stdout);
//	#endif
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a;
    cin>>a;
    fo(i,1,a+1)
    {
        cin>>b[i].fi;
        b[i].se=i;
    }
    fo(i,1,a)
    {
        cin>>c[i];
    }
    sort(b+1,b+2+a);
    sort(c+1,c+1+a);
    fo(i,1,a)
    {
        h1[i]=max((ll)0,b[i].fi-c[i]);
        h2[i]=max((ll)0,b[i+1].fi-c[i]);
    }
    fo(i,1,a)
    {
        mx1[i]=max(h1[i],mx1[i-1]);
    }
    ff(i,a,1)
    {
        mx2[i]=max(h2[i],mx2[i+1]);
    }
    fo(i,1,a+1)
    {
        ans[b[i].se]=max(mx1[i-1],mx2[i]);
    }
    fo(i,1,a+1) cout<<ans[i]<<" ";
 }
/*
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 1 ms 8540 KB Output is correct
14 Correct 2 ms 8540 KB Output is correct
15 Correct 2 ms 8540 KB Output is correct
16 Correct 2 ms 8540 KB Output is correct
17 Correct 2 ms 8668 KB Output is correct
18 Correct 2 ms 8536 KB Output is correct
19 Correct 2 ms 8692 KB Output is correct
20 Correct 2 ms 8536 KB Output is correct
21 Correct 2 ms 8540 KB Output is correct
22 Correct 2 ms 8668 KB Output is correct
23 Correct 2 ms 8540 KB Output is correct
24 Correct 2 ms 8540 KB Output is correct
25 Correct 2 ms 8540 KB Output is correct
26 Correct 2 ms 8540 KB Output is correct
27 Correct 2 ms 8540 KB Output is correct
28 Correct 2 ms 8540 KB Output is correct
29 Correct 2 ms 8540 KB Output is correct
30 Correct 2 ms 8704 KB Output is correct
31 Correct 2 ms 8540 KB Output is correct
32 Correct 2 ms 8672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8540 KB Output is correct
2 Correct 1 ms 8540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 8540 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 1 ms 8540 KB Output is correct
14 Correct 2 ms 8540 KB Output is correct
15 Correct 2 ms 8540 KB Output is correct
16 Correct 2 ms 8540 KB Output is correct
17 Correct 2 ms 8668 KB Output is correct
18 Correct 2 ms 8536 KB Output is correct
19 Correct 2 ms 8692 KB Output is correct
20 Correct 2 ms 8536 KB Output is correct
21 Correct 2 ms 8540 KB Output is correct
22 Correct 2 ms 8668 KB Output is correct
23 Correct 2 ms 8540 KB Output is correct
24 Correct 2 ms 8540 KB Output is correct
25 Correct 2 ms 8540 KB Output is correct
26 Correct 2 ms 8540 KB Output is correct
27 Correct 2 ms 8540 KB Output is correct
28 Correct 2 ms 8540 KB Output is correct
29 Correct 2 ms 8540 KB Output is correct
30 Correct 2 ms 8704 KB Output is correct
31 Correct 2 ms 8540 KB Output is correct
32 Correct 2 ms 8672 KB Output is correct
33 Correct 72 ms 17976 KB Output is correct
34 Correct 75 ms 18120 KB Output is correct
35 Correct 69 ms 17968 KB Output is correct
36 Correct 72 ms 18496 KB Output is correct
37 Correct 72 ms 18772 KB Output is correct
38 Correct 73 ms 18480 KB Output is correct
39 Correct 68 ms 17744 KB Output is correct
40 Correct 77 ms 17608 KB Output is correct
41 Correct 69 ms 17768 KB Output is correct
42 Correct 75 ms 17796 KB Output is correct
43 Correct 76 ms 17748 KB Output is correct
44 Correct 67 ms 17352 KB Output is correct
45 Correct 69 ms 17468 KB Output is correct
46 Correct 73 ms 17492 KB Output is correct
47 Correct 64 ms 17192 KB Output is correct
48 Correct 66 ms 17232 KB Output is correct
49 Correct 74 ms 17836 KB Output is correct
50 Correct 71 ms 17920 KB Output is correct
51 Correct 72 ms 17912 KB Output is correct
52 Correct 71 ms 17920 KB Output is correct
53 Correct 70 ms 18004 KB Output is correct