Submission #224021

#TimeUsernameProblemLanguageResultExecution timeMemory
224021errorgornJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
336 ms16480 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define endl '\n' #define debug(x) cout << #x << " is " << x << endl; #define rep(x,start,end) for(auto x=start-(start>end);x!=end-(start>end);x+=(start<end?1:-1)) #define all(x) x.begin(),x.end() ll MAX(ll a){return a;} ll MIN(ll a){return a;} template<typename... Args> ll MAX(ll a, Args... args) { return max(a,MAX(args...)); } template<typename... Args> ll MIN(ll a, Args... args) { return min(a,MIN(args...)); } #define indexed_set tree<ll, null_type, less<ll>,rb_tree_tag,tree_order_statistics_node_update> int n; vector<ii> a; vector<int> b; multiset<int> s; int ans[200005]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; int t; rep (x,0,n+1){ cin>>t; a.push_back(ii(t,x)); } rep(x,0,n){ cin>>t; b.push_back(t); } sort(all(a)); sort(all(b)); rep(x,0,n){ s.insert(max(a[x+1].first-b[x],0LL)); } ans[a[0].second]=*(--s.end()); rep(x,0,n){ s.erase(s.find(max(a[x+1].first-b[x],0LL))); s.insert(max(a[x].first-b[x],0LL)); ans[a[x+1].second]=*(--s.end()); } rep(x,0,n+1) cout<<ans[x]<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...