Submission #1115044

#TimeUsernameProblemLanguageResultExecution timeMemory
1115044AdamGSJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
199 ms19012 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ll n; cin >> n; vector <ll> pracownicy(n); vector <ll> krawaty(n+1); vector <ll> pre(n); vector <ll> suf(n); unordered_map <ll, ll> wyniki; for(int i = 0; i < n+1; i++){ cin >> krawaty[i]; } for(int i = 0; i < n; i++){ cin >> pracownicy[i]; } vector<ll> zapasowa = krawaty; sort(pracownicy.begin(), pracownicy.end()); sort(krawaty.begin(), krawaty.end()); pre[0] = max(krawaty[0] - pracownicy[0], 0ll); for(ll i = 1; i < n; i++){ pre[i] = max(pre[i-1], krawaty[i] - pracownicy[i]); } suf[n - 1] = max(krawaty[n]-pracownicy[n-1], 0ll); for(ll i = n-2; i >= 0; i--){ suf[i] = max(suf[i+1],krawaty[i+1]-pracownicy[i]); } wyniki[krawaty[0]] = suf[0]; for(ll i = 1; i < n; i++){ wyniki[krawaty[i]] = max(suf[i], pre[i-1]); } wyniki[krawaty[n]] = pre[n-1]; for(ll i = 0; i < n+1; i++){ cout << wyniki[zapasowa[i]] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...