제출 #470546

#제출 시각아이디문제언어결과실행 시간메모리
470546vincent97198Just Long Neckties (JOI20_ho_t1)C++14
1 / 100
2 ms576 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector<pair<int,int>> a(n+2),b(n+1); for(int i=1;i<=n+1;++i) cin >> a[i].first; for(int i=1;i<=n;++i) cin >> b[i].first; for(int i=1;i<=n+1;++i) a[i].second=i; sort(a.begin()+1,a.end()); sort(b.begin()+1,b.end()); vector<int> Lans(n+5,-1e18),Rans(n+5,-1e18); for(int i=1;i<=n;++i){ Lans[i]=max(Lans[i-1],max(0LL,a[i].first-b[i].first)); // cout << "Lans" << Lans[i] << '\n'; } for(int i=n+1;i>=2;--i){ Rans[i]=max(Rans[i+1],max(0LL,a[i].first-b[i-1].first)); // cout << "Rans" << Rans[i] << '\n'; } vector<int> ans(n+1); for(int i=1;i<=n+1;++i){ ans[a[i].second]=max(Lans[i-1],Rans[i+1]); // cout << "a[i].second" << a[i].second << '\n'; } for(int i=1;i<=n+1;++i) cout << ans[i] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...