제출 #1233869

#제출 시각아이디문제언어결과실행 시간메모리
1233869antromancapJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
59 ms6212 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, ans[N], b[N], f[N]; pair<int, int> a[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; 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); for (int i = n; i; i--) f[i] = max(f[i + 1], a[i + 1].first - b[i]); int cur = 0; b[n + 1] = 1e9; for (int i = 1; i <= n + 1; i++) { cur = max(cur, a[i].first - b[i]); ans[a[i].second] = max(cur, f[i]); } 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...