제출 #1221183

#제출 시각아이디문제언어결과실행 시간메모리
1221183takoshanavaJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
275 ms18068 KiB
#include <bits/stdc++.h> #define int long long #define pb push_backk #define fs first #define sc second using namespace std; signed main() { int n; cin >> n; vector<pair<int, int>> a(n + 1); vector<int> b(n); multiset<int> t; for(int i = 0; i < n + 1; i++) { cin >> a[i].fs; a[i].sc = i; } for(int i = 0; i < n; i++) cin >> b[i]; sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<int> ans(n+1, 0); for(int i = 0; i < n; i++) { t.insert(a[i+1].fs - b[i]); } ans[a[0].sc] = max(0LL, *t.rbegin()); for(int i = 0; i < n; i++) { t.erase(t.find(a[i+1].fs - b[i])); t.insert(a[i].fs - b[i]); ans[a[i+1].sc] = max(0LL, *t.rbegin()); } for(auto i : ans) cout << i << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...