제출 #1131496

#제출 시각아이디문제언어결과실행 시간메모리
1131496kasdoJust Long Neckties (JOI20_ho_t1)C++20
0 / 100
0 ms320 KiB
#include "bits/stdc++.h" using namespace std; #define int long long #define endl '\n' signed main () { cin.tie(0)->sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; pair<int, int> a[n + 5], b[n + 5]; for(int i=0; i<=n; i++) { cin>>a[i].first; a[i].second = i + 1; } for(int i=0; i<n; i++) { cin>>b[i].first; b[i].second = i + 1; } sort(a, a+n+1); sort(b, b+n); int p[n + 5] = {}, s[n + 5] = {}; s[a[n].second] = 0, p[a[0].second] = 0; for(int i=1; i<=n; i++) p[a[i].second] = max(p[a[i - 1].second], max(a[i - 1].first - b[i - 1].first, 0ll)); for(int i=n-1; i>=0; i--) s[a[i].second] = max(s[a[i + 1].second], max(a[i + 1].first - b[i].first, 0ll)); for(int i=0; i<=n; i++) { cout<<max(p[a[i].second], s[a[i].second])<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...