Submission #655582

#TimeUsernameProblemLanguageResultExecution timeMemory
655582happypotatoJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
291 ms9252 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> a[n + 2]; int b[n + 1]; for (int i = 1; i <= n + 1; i++) { cin >> a[i].first; a[i].second = i; } for (int i = 1; i <= n; i++) cin >> b[i]; sort(a + 1, a + n + 2); sort(b + 1, b + n + 1); int ans[n + 2]; for (int i = 1; i <= n + 1; i++) ans[i] = 0; int cur = 0; for (int i = 1; i <= n; i++) { cur = max(cur, max(a[i].first - b[i], 0)); ans[a[i + 1].second] = max(ans[a[i + 1].second], cur); } cur = 0; for (int i = n + 1; i >= 2; i--) { cur = max(cur, max(a[i].first - b[i - 1], 0)); ans[a[i - 1].second] = max(ans[a[i - 1].second], cur); } 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...