Submission #900147

#TimeUsernameProblemLanguageResultExecution timeMemory
900147andrei_iorgulescuJust Long Neckties (JOI20_ho_t1)C++14
9 / 100
1054 ms16304 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n,b[200005]; pair<int,int> a[200005]; int ans[200005]; int d1[200005],d2[200005]; int maxpref[200005],maxsuf[200005]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n + 1; i++) cin >> a[i].first,a[i].second = i; for (int i = 1; i <= n; i++) cin >> b[i]; sort(b + 1,b + n + 1); sort(a + 1,a + n + 2); for (int i = 1; i <= n; i++) d1[i] = abs(a[i].first - b[i]); for (int i = 1; i <= n; i++) d2[i] = abs(a[i + 1].first - b[i]); maxpref[0] = 0; maxsuf[n + 1] = 0; for (int i = 1; i <= n + 1; i++) { int mx = 0; for (int j = 1; j < i; j++) mx = max(mx,a[j].first - b[j]); for (int j = i; j <= n; j++) mx = max(mx,a[j + 1].first - b[j]); ans[a[i].second] = mx; } for (int i = 1; i <= n + 1; i++) cout << ans[i] << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...