Submission #792244

#TimeUsernameProblemLanguageResultExecution timeMemory
792244n3rm1nJust Long Neckties (JOI20_ho_t1)C++17
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 2e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long n, a[MAXN], b[MAXN]; void read() { cin >> n; for (int i = 1; i <= n + 1; ++ i) cin >> a[i]; for (int i = 1; i <= n; ++ i) cin >> b[i]; sort(a+1, a+n+2); sort(b+1, b+n+1); } long long dp0[MAXN], dp1[MAXN]; void solve() { for (int i = 1; i <= n; ++ i) { dp0[i] = dp0[i-1]; dp0[i] = max(dp0[i], max(1LL * 0, a[i] - b[i])); //cout << dp0[i] << " "; } // cout << endl; for (int i = n+1; i >= 1; -- i) { dp1[i] = dp1[i+1]; dp1[i] = max(dp1[i], max(1LL * 0, a[i] - b[i-1])); } for (int i = 1; i <= n+1; ++ i) { cout << max(dp0[i-1], dp1[i+1]) << " "; } cout << endl; } int main() { speed(); read(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...