제출 #568110

#제출 시각아이디문제언어결과실행 시간메모리
568110Ronin13Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
253 ms14624 KiB
#include<bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; int main(){ int n; cin >> n; pll a[n + 2]; for(int i = 1; i <= n + 1; i++){ cin >> a[i].f; a[i].s = i; } sort(a + 1, a + 2 + n); //reverse(a + 1, a + 2 + n); ll b[n + 1]; for(int i = 1; i <= n; i++) cin >> b[i]; sort(b + 1, b + 1 + n); //reverse(b + 1, b + 1 + n); ll pref[n + 1]; ll suf[n + 3]; pref[0] = 0; suf[n + 2] = 0; for(int i = 1; i <= n; i++){ pref[i] = max(pref[i - 1], a[i].f - b[i]); } for(int i = n + 1; i >= 2; i--){ suf[i] = max(suf[i + 1], a[i].f - b[i - 1]); } int ans[n + 2]; for(int i = 1; i <= n + 1; i++){ ans[a[i].s] = max(pref[i - 1], suf[i + 1]); } for(int i = 1; i <= n + 1; i++) cout << ans[i] << ' '; cout << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...