Submission #202303

#TimeUsernameProblemLanguageResultExecution timeMemory
202303giorgikobJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
524 ms14836 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; const int N = 1e6 + 69; int n,x; int B[N],ANS[N]; pair<int,int> A[N]; set< pair<int,int> > S; int main(){ cin>>n; for(int i=1;i<=n+1;i++){ cin>>x; A[i] = {x,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++){ S.insert( { max(A[i].ff-B[i-1],0), i } ); } ANS[ A[1].ss ] = (*S.rbegin()).ff; for(int i=2;i<=n+1;i++){ S.erase( { max(A[i].ff-B[i-1],0), i } ); S.insert( { max(A[i-1].ff-B[i-1],0), i-1 } ); ANS[ A[i].ss ] = (*S.rbegin()).ff; } 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...