Submission #201845

#TimeUsernameProblemLanguageResultExecution timeMemory
201845nvmdavaJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
306 ms14828 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define ll long long #define ff first #define ss second #define N 200002 #define MOD 1000000007 int a[N], ans[N]; vector<pair<int, int> > ne; multiset<int> in; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i = 0; i <= n; ++i){ int k; cin>>k; ne.push_back({k, i}); } sort(ne.begin(), ne.end()); for(int i = 0; i < n; ++i){ cin>>a[i]; } sort(a, a + n); for(int i = 0; i < n; ++i) in.insert(a[i] - ne[i].ff); ans[ne[n].ss] = *in.begin(); for(int i = n - 1; i >= 0; --i){ in.erase(in.find(a[i] - ne[i].ff)); in.insert(a[i] - ne[i + 1].ff); ans[ne[i].ss] = *in.begin(); } for(int i = 0; i <= n; ++i) cout<<max(0, -ans[i])<<' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...