Submission #889357

#TimeUsernameProblemLanguageResultExecution timeMemory
889357Perl32Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
86 ms10836 KiB
//I wrote this code 4 u <3 #include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif signed main(int32_t argc, char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, int>> a(n + 1); for (int i = 0; i <= n; ++i) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); vector<int> b(n); for (int i = 0; i < n; ++i) { cin >> b[i]; } sort(b.begin(), b.end()); vector<int> pref(n + 2, 0), suf(n + 2, 0); for (int i = 0; i < n; ++i) { pref[i + 1] = max(pref[i], a[i].first - b[i]); } for (int i = n - 1; i > -1; --i) { suf[i] = max(suf[i + 1], a[i + 1].first - b[i]); } vector<int> ans(n + 1); for (int i = 0; i <= n; ++i) { ans[a[i].second] = max(pref[i], suf[i]); } for (auto x : ans) { cout << x << ' '; } } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...