Submission #906407

#TimeUsernameProblemLanguageResultExecution timeMemory
906407Le_Minh_DucJust Long Neckties (JOI20_ho_t1)C++14
0 / 100
2 ms6488 KiB
#include<bits/stdc++.h> #define ll long long #define f first #define s second using namespace std; ll n, a[(int)2e5+5], b[(int)2e5+5], c1[(int)2e5+5], c2[(int)2e5+5]; pair <ll, ll> c[(int)2e5+5]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(int i = 1; i <= n+1; i++) cin>>a[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+1; i++) cout<<a[i]<<" "; // // cout<<endl; // // for(int i = 1; i <= n; i++) cout<<b[i]<<" "; // // cout<<endl; c1[0] = -1e18; c2[n+1] = -1e18; for(int i = 1; i <= n; i++){ c[i].f = max(0ll, a[i]-b[i]); c[i].s = max(0ll, a[i+1]-b[i]); c1[i] = max(c1[i-1], c[i].f); } for(int i = n; i >= 1; i--){ c2[i] = max(c2[i+1], c[i].s); } // for(int i = 1; i <= n; i++) cout<<c[i].s<<" "; for(int i = 1; i <= n+1; i++){ cout<<max(c1[i-1], c2[i])<<" "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...