Submission #418042

#TimeUsernameProblemLanguageResultExecution timeMemory
418042FerThugGato12500Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
123 ms13232 KiB
#include<bits/stdc++.h> #define forn(i, n) for(int i = 0; i < int(n); i++) #define ll long long using namespace std; const int lmt = 200005; struct wer{ int v, i, otheri; }; bool operator < (const wer &a, const wer &b){ return a.v < b.v; } wer p[lmt]; int a[lmt]; int ans[lmt]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; forn(i, n+1){ cin>>p[i].v; p[i].i = i; } forn(i, n) cin>>a[i]; sort(p, p+n+1); sort(a,a+n); priority_queue<wer> mqun; forn(i, n){ mqun.push({max(p[i].v-a[i],0),p[i].i,i}); } ans[p[n].i] = mqun.top().v; for(int i = n; i>= 0; i--){ mqun.push({max(p[i+1].v - a[i], 0), p[i].i, -1}); while(mqun.top().otheri >= i){ mqun.pop(); } ans[p[i].i] = mqun.top().v; } forn(i, n+1){ cout<<ans[i]<<" "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...