Submission #543163

#TimeUsernameProblemLanguageResultExecution timeMemory
543163jesus_coconutJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
277 ms18656 KiB
#include <bits/stdc++.h> #define F first #define S second #define all(a) begin(a), end(a) #define pb push_back #define eb emplace_back using namespace std; using ll = long long; void solve() { int n; cin >> n; vector<int> a(n+1); vector<int> b(n); vector<int> ind(n+1); iota(all(ind), 0); for (auto &it : a) cin >> it; for (auto &it : b) cin >> it; sort(all(b)); sort(all(ind), [&](int i, int j) { return a[i] < a[j]; }); vector<int> ans(n+1); multiset<int, greater<>> s; s.insert(0); for (int i = 0; i < n; ++i) { s.insert(a[ind[i]] - b[i]); } ans[ind[n]] = *s.begin(); for (int i = n - 1; i >= 0; --i) { s.erase(s.find(a[ind[i]] - b[i])); s.insert(a[ind[i+1]] - b[i]); ans[ind[i]] = *s.begin(); } for (auto a : ans) cout << a << ' '; cout << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...