Submission #493793

#TimeUsernameProblemLanguageResultExecution timeMemory
493793BiazJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
238 ms23336 KiB
#include <bits/stdc++.h> #define int long long #define double long double #define Nanase_Kurumi_aka_menhera_chan_is_mine ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define pb push_back #define pi pair<int, int> #define ALL(i) i.begin(),i.end() #define gcd(i,j) __gcd(i,j) #define fi first #define se second #define eps 0.00000001 #define ist insert #define DNE nullptr //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") //#pragma GCC optimize("O2") int max(int x,int y){return x>=y?x:y;} int min(int x,int y){return x>=y?y:x;} using namespace std; typedef long long ll; const int N=200005; const int M=100000005; const int MOD=998244353;//1000000007; const int INF=2147483647;//1000000000000000; int n; pi a[N]; int res[N],b[N]; multiset<int>st; inline void sol(){ cin >>n; for (int i=1;i<=n+1;i++) cin >>a[i].fi,a[i].se=i; for (int i=1;i<=n;i++) cin >>b[i]; sort(a+1,a+n+2);sort(b+1,b+n+1); vector<int> c(n+1); for (int i=1;i<=n;i++) st.ist(max(0,a[i].fi-b[i])),c[i]=a[i].fi; res[a[n+1].se]=*st.rbegin(); int pre=a[n+1].fi; for (int i=n;i>=1;i--){ st.erase(max(0,a[i].fi-b[i])); st.ist(max(0,pre-b[i])); res[a[i].se]=*st.rbegin(); pre=a[i].fi; } for (int i=1;i<=n+1;i++) cout <<res[i]<<' '; } signed main(){ Nanase_Kurumi_aka_menhera_chan_is_mine int _=1; //cin >>_; while (_--) sol(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...