제출 #1136749

#제출 시각아이디문제언어결과실행 시간메모리
1136749tsengangJust Long Neckties (JOI20_ho_t1)C++20
100 / 100
228 ms17940 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define pb push_back #define ertunt return #define vodka void int main(){ ll n; cin >> n; ll b[n+1]; pair<ll,ll> a[n+2]; for(ll i = 0; i < n+1; i++){ cin >> a[i].ff; a[i].ss = i; } for(ll i = 0; i < n; i++)cin >> b[i]; sort(a,a+n+1); sort(b,b+n); vector<ll>ans(n+5); multiset<ll,greater<ll>>st; for(ll i = 0; i < n; i++)st.insert(a[i].ff - b[i]); ans[a[n].ss]=*st.begin(); for(ll i = n-1; i >= 0; i--){ st.erase(st.find(a[i].ff - b[i])); st.insert(a[i+1].ff - b[i]); ans[a[i].ss]=*st.begin(); } for(ll i = 0; i <= n; i++)cout << max(0ll, ans[i]) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...