Submission #276016

#TimeUsernameProblemLanguageResultExecution timeMemory
276016islingrJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
119 ms10872 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define per(i, a, b) for (auto i = (b); i-- > (a); ) const int N = 1 << 18; pair<int, int> a[N]; int b[N], c[N], p[N], s[N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; rep(i, 0, n + 1) { int x; cin >> x; a[i] = {x, i}; } rep(i, 0, n) cin >> b[i]; sort(a, a + n + 1); sort(b, b + n); rep(i, 0, n) p[i + 1] = max(p[i], a[i].first - b[i]); per(i, 0, n) s[i] = max(s[i + 1], a[i + 1].first - b[i]); rep(i, 0, n + 1) c[a[i].second] = max(p[i], s[i]); rep(i, 0, n + 1) cout << c[i] << ' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...