Submission #991589

#TimeUsernameProblemLanguageResultExecution timeMemory
991589IrateJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
81 ms6996 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<int, int>>a(n + 2); vector<int> b(n + 1); for(int i = 1;i <= n + 1;++i){ cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); for(int i = 1;i <= n;++i){ cin >> b[i]; } sort(b.begin(), b.end()); vector<int>pref_mx(n + 1), suff_mx(n + 3); for(int i = 1;i <= n;++i){ pref_mx[i] = pref_mx[i - 1]; pref_mx[i] = max({pref_mx[i], a[i].first - b[i], 0}); } for(int i = n + 1;i >= 1;--i){ suff_mx[i] = suff_mx[i + 1]; suff_mx[i] = max({suff_mx[i], a[i].first - b[i - 1], 0}); } vector<int>ans(n + 2); for(int i = 1;i <= n + 1;++i){ ans[a[i].second] = max(pref_mx[i - 1], suff_mx[i + 1]); } for(int i = 1;i <= n + 1;++i){ cout << ans[i] << ' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...