Submission #924505

#TimeUsernameProblemLanguageResultExecution timeMemory
924505mochaJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
191 ms19124 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int mx = 2e5+5; int n; pair<int,int> a[mx]; int b[mx]; int d[mx], rd[mx]; int ans[mx]; signed main() { cin.tie(0);ios::sync_with_stdio(0); cin >> n; for (int i=0;i<=n;i++) { cin >> a[i].first; a[i].second = i; } for (int i=0;i<n;i++) { cin >> b[i]; } sort(a,a+n+1); sort(b,b+n); multiset<int> st; for (int i=0;i<n;i++) { st.insert(max(a[i+1].first-b[i],0LL)); // cout << max(a[i+1].first-b[i],0LL) << "\n"; } ans[a[0].second] = *--st.end(); // cout << a[0].second << " " << st.size() << "\n"; for (int i=0;i<n;i++) { st.erase(st.find(max(a[i+1].first-b[i], 0LL))); // cout << max(a[i+1].first-b[i], 0LL) << " " << max(a[i].first-b[i], 0LL) << "\n"; st.insert(max(a[i].first-b[i],0LL)); // cout << a[i].second << "owo\n"; ans[a[i+1].second] = *--st.end(); } for (int i=0;i<=n;i++) { cout << ans[i] << " "; } cout << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...