제출 #549902

#제출 시각아이디문제언어결과실행 시간메모리
549902HanksburgerJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
316 ms18648 KiB
#include <bits/stdc++.h> using namespace std; int b[200005], ans[200005]; pair<int, int> a[200005]; multiset<int> s; multiset<int>::iterator itr; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; 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(a+1, a+n+2); sort(b+1, b+n+1); for (int i=1; i<=n; i++) s.insert(max(a[i].first-b[i], 0)); itr=s.end(); itr--; ans[a[n+1].second]=(*itr); for (int i=n; i>=1; i--) { s.erase(s.find(max(a[i].first-b[i], 0))); s.insert(max(a[i+1].first-b[i], 0)); itr=s.end(); itr--; ans[a[i].second]=(*itr); } 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...