Submission #1150445

#TimeUsernameProblemLanguageResultExecution timeMemory
1150445tvgkJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
87 ms8520 KiB
#include<bits/stdc++.h> using namespace std; #define task "a" #define se second #define fi first #define ll long long #define ii pair<ll, ll> const long mxN = 2e5 + 7; int n, a[mxN], ans[mxN]; ll mx[mxN]; ii t[mxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); cin >> n; for (int i = 1; i <= n + 1; i++) { cin >> t[i].fi; t[i].se = i; } for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); sort(t + 1, t + n + 2); for (int i = 1; i <= n; i++) mx[i] = max(mx[i - 1], t[i].fi - a[i]); ll cur = 0; a[0] = t[1].fi; for (int i = n + 1; i >= 1; i--) { ans[t[i].se] = max(mx[i - 1], cur); cur = max(cur, t[i].fi - a[i - 1]); } for (int i = 1; i <= n + 1; i++) cout << ans[i] << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...