Submission #532136

#TimeUsernameProblemLanguageResultExecution timeMemory
532136chenyanJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
122 ms13296 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define N 200010 #define pii pair<int,int> #define ff first #define ss second #define all(x) x.begin(),x.end() #define pb emplace_back int b[N]; pii a[N]; vector<pii>ans; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,i,j; cin>>n; for(i=0;i<=n;i++) cin>>a[i].ff,a[i].ss=i; for(i=0;i<n;i++) cin>>b[i]; sort(a,a+n+1); sort(b,b+n); int mx=0; for(i=0;i<n;i++) mx=max(mx,a[i].ff-b[i]); ans.pb(a[i].ss,mx); for(i=n-1;i>=0;i--){ mx=max(mx,a[i+1].ff-b[i]); ans.pb(a[i].ss,mx); } sort(all(ans)); for(auto u:ans) cout<<u.ss<<' '; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:16:10: warning: unused variable 'j' [-Wunused-variable]
   16 |  int n,i,j;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...