제출 #529786

#제출 시각아이디문제언어결과실행 시간메모리
529786Alex_tz307Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
88 ms10052 KiB
#include <bits/stdc++.h> using namespace std; void testCase() { int n; cin >> n; vector<pair<int, int>> a(n + 2); for (int i = 1; i <= n + 1; ++i) { cin >> a[i].first; a[i].second = i; } sort(a.begin() + 1, a.end()); vector<int> b(n + 2); for (int i = 1; i <= n; ++i) { cin >> b[i]; } sort(b.begin() + 1, b.begin() + n + 1); vector<int> sufMax(n + 2); for (int i = n; i > 0; --i) { sufMax[i] = max(a[i + 1].first - b[i], sufMax[i + 1]); } vector<int> sol(n + 2); int pref = 0; for (int i = 1; i <= n + 1; ++i) { sol[a[i].second] = max(pref, sufMax[i]); pref = max(pref, a[i].first - b[i]); } for (int i = 1; i <= n + 1; ++i) { cout << sol[i] << ' '; } cout << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int tests = 1; for (int tc = 0; tc < tests; ++tc) { testCase(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...