제출 #1281782

#제출 시각아이디문제언어결과실행 시간메모리
1281782peanutJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
73 ms6176 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int, int>> a(n+1); vector<int> b(n); for (int i = 0; i <= n; ++i) { cin >> a[i].first; a[i].second = i; } for (int i = 0; i < n; ++i) cin >> b[i]; sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<int> suf(n+2, 0); vector<int> ans(n+1); for (int i = n; i >= 1; --i) suf[i] = max(suf[i+1], max(0, a[i].first - b[i-1])); int ye = 0; for (int i = 1; i <= n+1; ++i) { ans[a[i-1].second] = max(ye, suf[i]); ye = max(ye, max(0, a[i-1].first - b[i-1])); } for (auto i : ans) cout << i << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...