Submission #747722

#TimeUsernameProblemLanguageResultExecution timeMemory
747722prairie2022Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
125 ms10812 KiB
#include <bits/stdc++.h> //#define int long long #define fastio cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); using namespace std; int main(){ int n; fastio cin >> n; vector<pair<int, int>> a(n+1); vector<int> b(n), m1(n+1), m2(n+1), ans(n+1); for(int i=0; i<=n; i++){ cin >> a[i].first; a[i].second = i; } for(int i=0; i<n; i++) cin >> b[i]; sort(a.begin(), a.end()); sort(b.begin(), b.end()); m1[0] = max(a[0].first-b[0], 0); m2[n-1] = max(a[n].first-b[n-1], 0); for(int i=1; i<n; i++) m1[i] = max(m1[i-1], a[i].first-b[i]); for(int i=n-2; i>-1; i--) m2[i] = max(m2[i+1], a[i+1].first-b[i]); ans[a[0].second] = m2[0]; for(int i=1; i<n; i++) ans[a[i].second]= max(m2[i], m1[i-1]); ans[a[n].second] = m1[n-1]; for(const int &aa: ans) cout << aa << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...