Submission #941875

#TimeUsernameProblemLanguageResultExecution timeMemory
941875LitusianoJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
188 ms15580 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n; cin>>n; int cnt = 0; vector<pair<int,int>> v(n+1); for(auto& i : v) cnt++,cin>>i.first, i.second = cnt-1; vector<int> b(n); for(int& i : b) cin>>i; sort(b.begin(),b.end()); // cout<<endl; vector<int> ans(n+1); sort(v.begin(),v.end()); vector<int> pre(n+1,0), suf(n+1,0); for(int i = 0; i<n; i++){ pre[i+1] = max(pre[i], v[i].first-b[i]); } for(int i = n-1; i>=0; i--){ suf[i] = max(suf[i+1], v[i+1].first - b[i]); } // for(int i : pre) cout<<i<<" "; // cout<<endl; // for(int i : suf) cout<<i<<" "; cout<<endl; for(int i = 0; i<=n; i++){ ans[v[i].second] = max(pre[i], suf[i]); } for(int i : ans) cout<<i<<" "; cout<<endl; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:28:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   28 |  for(int i : ans) cout<<i<<" "; cout<<endl;
      |  ^~~
ho_t1.cpp:28:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   28 |  for(int i : ans) cout<<i<<" "; cout<<endl;
      |                                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...