Submission #1114929

#TimeUsernameProblemLanguageResultExecution timeMemory
1114929AdamGSJust Long Neckties (JOI20_ho_t1)C++17
0 / 100
1 ms336 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<ll> ludzie; vector<ll> szef; ll p1; int n; cin >> n; for (int i = 0; n >= i; i++) { cin >> p1; szef.push_back(p1); } for (int i = 0; n > i; i++) { cin >> p1; ludzie.push_back(p1); } sort(ludzie.begin(), ludzie.end()); sort(szef.begin(), szef.end()); vector<ll> pref(n+2); vector<ll> suf(n + 2); pref[0] = (ll)0; suf[n + 1] = (ll)0; for (int i = 1; n >= i; i++) { pref[i] = max(pref[i - 1], szef[i - 1] - ludzie[i - 1]); //cout << i << " " << pref[i] << "\n"; } for (int i = n; i > 0; i--) { suf[i] = max(suf[i + 1], szef[i] - ludzie[i - 1]); //cout << i << " " << suf[i] << "\n"; } for (int i = 1; n + 1 >= i; i++) { cout << max(pref[i - 1], suf[i]) << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...