Submission #1114674

#TimeUsernameProblemLanguageResultExecution timeMemory
1114674AdamGSJust Long Neckties (JOI20_ho_t1)C++17
0 / 100
1 ms336 KiB
#include<bits/stdc++.h> using namespace std; int granica(int x, int v,int y){ return min(max(x, v), y); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n+1); vector<int> b(n); vector<int> pref(n+1, 0); vector<int> suf(n+1, 0); for (int i = 0; i <= n; i++){ cin >> a[i]; } for (int i = 0; i < n; i++){ cin >> b[i]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<int> res(n+1); int aktual = 0; for (int i = 0; i < n; i++){ // pref czyli jak usuwamy ity elem np. ostatni int h = a[i] - b[i]; aktual = max(aktual, h); pref[i] = aktual; } res[n] = aktual; aktual = 0; for (int i = n-1; i > 0; i--){ // suf co jak zabierzemy ity elem laczymy na skos int h = a[i+1] - b[i]; aktual = max(aktual, h); suf[i] = aktual; } res[0] = aktual; for (int i = 1; i < n; i++){ // zabieramy ity int h = max(pref[i-1], suf[i]); res[i] = h; } for (int i = 0; i <= n; i++){ cout << res[i] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...