Submission #212272

#TimeUsernameProblemLanguageResultExecution timeMemory
212272grtJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
168 ms12644 KiB
#include <bits/stdc++.h> #define PB push_back #define ST first #define ND second #define _ ios_base::sync_with_stdio(0); cin.tie(0); //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; const int nax = 200*1000+10; int n; pi a[nax]; int b[nax]; int ans[nax]; priority_queue<pi>PQ; int main() {_ cin>>n; for(int i=1; i<=n+1; i++) { cin>>a[i].ST; a[i].ND = i; } for(int i=1; i<=n; i++) cin>>b[i]; sort(a+1,a+n+2); sort(b+1,b+n+1); for(int i=2; i<=n+1; i++) { PQ.push({a[i].ST-b[i-1],i}); } for(int i=1; i<=n+1; i++) { ans[a[i].ND] = max(0,PQ.top().ST); PQ.push({a[i].ST-b[i],i+n+1}); while(!PQ.empty()&&PQ.top().ND<=i+1) { PQ.pop(); } } 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...