제출 #733493

#제출 시각아이디문제언어결과실행 시간메모리
733493pccJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
116 ms17116 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define fs first #define sc second void solve(){ int n; cin>>n; pll arr[n+1]; for(int i = 0;i<=n;i++){ arr[i].sc = i; cin>>arr[i].fs; } pll brr[n]; for(int i = 0;i<n;i++){ brr[i].sc = i; cin>>brr[i].fs; } sort(arr,arr+n+1); sort(brr,brr+n); ll pref[n+1]; ll suf[n+1]; pref[0] = max(0LL,arr[0].fs-brr[0].fs); ll ans[n+1]; for(int i = 1;i<n;i++){ pref[i] = max(pref[i-1],max(0LL,arr[i].fs-brr[i].fs)); } suf[n] = max(0LL,arr[n].fs-brr[n-1].fs); for(int i = n-1;i>=1;i--){ suf[i] = max(suf[i+1],max(0LL,arr[i].fs-brr[i-1].fs)); } ans[arr[0].sc] = suf[1]; ans[arr[n].sc] = pref[n-1]; for(int i = 1;i<n;i++){ ans[arr[i].sc] = max(pref[i-1],suf[i+1]); } for(int i = 0;i<=n;i++)cout<<ans[i]<<' ';cout<<'\n'; return; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; while(t--)solve(); }

컴파일 시 표준 에러 (stderr) 메시지

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:41:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |  for(int i = 0;i<=n;i++)cout<<ans[i]<<' ';cout<<'\n';
      |  ^~~
ho_t1.cpp:41:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   41 |  for(int i = 0;i<=n;i++)cout<<ans[i]<<' ';cout<<'\n';
      |                                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...