Submission #702462

#TimeUsernameProblemLanguageResultExecution timeMemory
702462Koful123Just Long Neckties (JOI20_ho_t1)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() void solve(){ int n; cin >> n; vector<int> a(n + 1),b(n); for(int i = 0; i < n + 1; i++){ cin >> a[i]; } for(int i = 0; i < n; i++){ cin >> b[i]; } sort(all(a)); sort(all(b)); vector<int> one(n + 1),two(n + 2); for(int i = 0; i < n; i++){ one[i] = max((i > 0 ? one[i - 1] : 0),a[i] - b[i]); } for(int i = n; i >= 1; i--){ two[i] = max(two[i + 1],a[i] - b[i - 1]); } for(int i = 0; i < n + 1; i++){ cout << max((i + 1 < n + 1 ? two[i + 1] : 0),(i > 0 ? one[i - 1] : 0)) << ' '; } cout << endl; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...