제출 #763092

#제출 시각아이디문제언어결과실행 시간메모리
763092vjudge1Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
89 ms49208 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second const int maxn = 1e6+5; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; pair<int, int> a[maxn]; for (int i = 1; i <= n+1; i++){ cin >> a[i].fi; a[i].se = i; } int b[maxn]; for (int i = 1; i <= n; i++) cin >> b[i]; sort(a + 1, a + n + 2); sort(b + 1, b + n + 1); int prefix[maxn], suffix[maxn]; for (int i = 1; i <= n; i++) prefix[i] = max(prefix[i-1], a[i].fi - b[i]); for (int i = n; i >= 1; i--) suffix[i] = max(suffix[i+1], a[i+1].fi - b[i]); int kq[maxn]; for (int i = 1; i <= n+1; i++) kq[a[i].se] = max(prefix[i-1], suffix[i]); for (int i = 1; i <= n+1; i++) cout << kq[i] << ' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...