Submission #201347

#TimeUsernameProblemLanguageResultExecution timeMemory
201347Mamnoon_SiamJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
341 ms7160 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int maxn = 2e5 + 5; int n; int a[maxn], b[maxn], p[maxn], s[maxn]; int ord[maxn], ans[maxn]; int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif cin >> n; for(int i = 1; i <= n+1; i++) { cin >> a[i]; } for(int i = 1; i <= n; i++) { cin >> b[i]; } iota(ord + 1, ord + 2 + n, 1); sort(ord + 1, ord + 2 + n, [](int i, int j){ return a[i] < a[j]; }); sort(a + 1, a + 2 + n); sort(b + 1, b + 1 + n); for(int i = n+1; i > 1; i--) { s[i] = max(s[i+1], a[i] - b[i-1]); } for(int i = 1; i <= n; i++) { p[i] = max(p[i-1], a[i] - b[i]); } for(int i = 1; i <= n+1; i++) { // cout << max(p[i-1], s[i+1]) << ' '; ans[ord[i]] = max(p[i-1], s[i+1]); } for(int i = 1; i <= n+1; i++) cout << ans[i] << ' '; cout << endl; return 0; }

Compilation message (stderr)

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