제출 #1151217

#제출 시각아이디문제언어결과실행 시간메모리
1151217KK_1729Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
264 ms19372 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define pb push_back #define all(a) a.begin(), a.end() #define endl "\n" void printVector(vector<int> a){ for (auto x: a) cout << x << " "; cout << endl; } void solve(){ int n; cin >> n; vector<pair<int, int>> a(n+1); FOR(i,0,n+1){ cin >> a[i].first; a[i].second = i; } sort(all(a)); vector<int> b(n); FOR(i,0,n) cin >> b[i]; sort(all(b)); vector<int> ans(n+1); multiset<int, greater<int>> s; FOR(i,0,n){ s.insert(max(0ll, a[i+1].first-b[i])); } FOR(i,0,n){ // cout s.begin() << endl; ans[a[i].second] = *s.begin(); s.erase(s.find(max(0ll, a[i+1].first-b[i]))); s.insert(max(0ll, a[i].first-b[i])); // cout << *s.begin() << endl; } ans[a[n].second] = *s.begin(); printVector(ans); } int32_t main(){ ios::sync_with_stdio(false);cin.tie(nullptr); int t = 1; // cin >> t; while (t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...