Submission #1108285

#TimeUsernameProblemLanguageResultExecution timeMemory
1108285overwatch9Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
298 ms20296 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector <pair <int, int>> a(n+1); vector <int> b(n); for (int i = 0; i < n+1; i++) { cin >> a[i].first; a[i].second = i; } for (int i = 0; i < n; i++) cin >> b[i]; sort(b.begin(), b.end()); vector <pair <int, int>> a2 = a; sort(a2.begin(), a2.end()); multiset <int> d; for (int i = 1; i < n+1; i++) { d.insert(max(0, a2[i].first - b[i-1])); } vector <int> ans(n+1); ans[a2[0].second] = *d.rbegin(); for (int i = 0; i < n; i++) { d.insert(max(0, a2[i].first - b[i])); d.erase(d.find(max(0, a2[i+1].first - b[i]))); ans[a2[i+1].second] = *d.rbegin(); } for (int i = 0; i < n+1; i++) cout << ans[i] << ' '; cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...