제출 #762956

#제출 시각아이디문제언어결과실행 시간메모리
762956vjudge1Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
85 ms10060 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pii; #define fi first #define se second #define gcd __gcd #define endl '\n' const int N=200050,M=1000000007; const ll INF=0x3f3f3f3f3f3f3f3f; pii a[N]; ll n, b[N], res[N], ans[N]; signed main(){ ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); cin>>n; for(ll i=0; i<=n; ++i){ cin>>a[i].fi; a[i].se=i; } for(ll i=0; i<n; ++i) cin>>b[i]; sort(a, a+n+1); sort(b, b+n); for(ll i=0; i<n; ++i) res[i+1]=max(res[i], max(0LL, a[i].fi-b[i])); // for(ll i=0; i<=n; ++i) cout<<res[i]<<" "; // cout<<endl; for(ll i=n; i; --i) res[i-1]=max(res[i], max(0LL, a[i].fi-b[i-1])); for(ll i=0; i<=n; ++i) ans[a[i].se]=res[i]; for(ll i=0; i<=n; ++i) cout<<ans[i]<<" "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...