Submission #921417

#TimeUsernameProblemLanguageResultExecution timeMemory
921417AverageAmogusEnjoyerJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
297 ms19532 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; } template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; } constexpr int nax = 200200; pair<int,int> a[nax]; int b[nax]; int n; ll ans[nax]; int main() { cin >> n; 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,a+n+1); sort(b,b+n); multiset<ll> res; for (int i=0;i<n;i++) { res.insert(max(0,a[i+1].first-b[i])); } ans[a[0].second] = *res.rbegin(); for (int i=1;i<=n;i++) { res.erase(res.find(max(0,a[i].first-b[i-1]))); res.insert(max(0,a[i-1].first-b[i-1])); ans[a[i].second] = *res.rbegin(); } for (int i=0;i<=n;i++) { cout << ans[i] << " "; } cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...