Submission #1094364

#TimeUsernameProblemLanguageResultExecution timeMemory
1094364imarnJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
75 ms10836 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx2") #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define plx pair<ll,int> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define vl vector<ll> #define vvi vector<vi> using namespace std; const int mxn=2e5+5; int t[2*mxn]{0}; void upd(int i,int amt,int sz){ i+=sz;t[i]=amt; for(i>>=1;i;i>>=1)t[i]=max(t[2*i],t[2*i+1]); } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n;cin>>n;pii a[n+1];int b[n]; for(int i=0;i<n+1;i++)cin>>a[i].f,a[i].s=i; for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n); for(int i=0;i<n;i++)t[i+n]=a[i+1].f-b[i]; for(int i=n-1;i>0;i--)t[i]=max(t[2*i],t[2*i+1]); int rs[n+1]={0}; for(int i=0;i<n+1;i++){ rs[a[i].s] = max(t[1],0);upd(i,a[i].f-b[i],n); }for(int i=0;i<n+1;i++)cout<<rs[i]<<' '; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:26:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   26 |     for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n);
      |     ^~~
ho_t1.cpp:26:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |     for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n);
      |                                   ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...