Submission #286141

#TimeUsernameProblemLanguageResultExecution timeMemory
286141reymontada61Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
639 ms18680 KiB
#include <bits/stdc++.h> using namespace std; int n; const int MXN = 200005; pair<int, int> arr[MXN]; int brr[MXN]; multiset<int> pairs; void join(int a, int b) { int x = max(0, arr[a].first - brr[b]); pairs.insert(x); } void unjoin(int a, int b) { int x = max(0, arr[a].first - brr[b]); pairs.erase(pairs.lower_bound(x)); } int score() { return *(--pairs.end()); } signed main() { cin >> n; for (int i=1; i<=n+1; i++) { cin >> arr[i].first; arr[i].second = i; } for (int i=1; i<=n; i++) { cin >> brr[i]; } sort(arr+1, arr+n+2); sort(brr+1, brr+n+1); for (int i=1; i<=n; i++) { join(i+1, i); } vector<int> ans(n+2); ans[arr[1].second] = score(); for (int i=1; i<=n; i++) { unjoin(i+1, i); join(i, i); ans[arr[i+1].second] = score(); } for (int i=1; i<=n+1; i++) cout << ans[i] << ' '; cout << endl; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:52:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |  for (int i=1; i<=n+1; i++) cout << ans[i] << ' '; cout << endl;
      |  ^~~
ho_t1.cpp:52:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   52 |  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...