Submission #1318666

#TimeUsernameProblemLanguageResultExecution timeMemory
1318666khanhphucscratchJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
71 ms7096 KiB
#include<bits/stdc++.h> using namespace std; pair<int, int> a[200005]; int b[200005], prefix[200005], suffix[200005], ans[200005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin>>n; for(int i = 1; i <= n+1; i++){ cin>>a[i].first; a[i].second = 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 = 1; i <= n; i++) prefix[i] = max(prefix[i-1], a[i].first - b[i]); for(int i = n+1; i >= 2; i--) suffix[i] = max(suffix[i+1], a[i].first - b[i-1]); for(int i = 1; i <= n+1; i++) ans[a[i].second] = max(prefix[i-1], suffix[i+1]); for(int i = 1; i <= n+1; i++) cout<<max(ans[i], 0)<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...