Submission #996523

#TimeUsernameProblemLanguageResultExecution timeMemory
996523makravJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
78 ms10836 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define all(a) (a).begin(), (a).end() #define sz(a) (int) a.size() #define pb push_back #define ff first #define sc second #define pii pair<int, int> #define f(i, l, r) for (int i = (l); i < (r); i++) #define double ld signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, int>> a(n + 1); vector<int> b(n); for (int i = 0; i < n + 1; i++) { cin >> a[i].first; a[i].second = i; } for (int i = 0; i < n; i++) cin >> b[i]; sort(all(a)); sort(all(b)); vector<int> pref(n+1,0), suff(n+1,0); for (int i = 1; i <= n; i++) { pref[i] = max(pref[i - 1], a[i - 1].first - b[i - 1]); suff[i] = max(suff[i - 1], a[n + 1 - i].first - b[n - i]); } vector<int> pos(n + 1, 0); for (int i = 0; i <= n; i++) pos[a[i].second] = i; for (int i = 0; i <= n; i++) { cout << max(pref[pos[i]], suff[n - pos[i]]) << ' '; } cout<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...