제출 #925195

#제출 시각아이디문제언어결과실행 시간메모리
925195ymwangJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
74 ms13900 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<long long, int>; const int N = 2e5+5; pii a[N]; long long b[N], suf[N], ans[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i=0; i<n+1; i++) { cin >> a[i].first; a[i].second = i; } for(int i=0; i<n; i++) cin >> b[i]; sort(b, b+n); sort(a, a+n+1); for(int i=n; i>0; i--) suf[i] = max(suf[i+1], a[i].first - b[i-1]); ans[a[0].second] = suf[1]; long long now = max(a[0].first - b[0], 0LL); for(int i=1; i<n+1; i++) { ans[a[i].second] = max({now, suf[i+1]}); now = max(now, a[i].first - b[i]); } for(int i=0; i<n+1; i++) cout << ans[i] << " "; cout << "\n"; } /* 3 4 3 7 6 2 6 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...