Submission #636496

#TimeUsernameProblemLanguageResultExecution timeMemory
636496Omar_ElgedawyJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
304 ms21780 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define F first #define S second #define el endl #define cout(x) for(auto v:x)cout<<v<<' ' #define cin(x) for(auto &v:x)cin>>v; #define pb(x) push_back(x) #define all(x) x.begin(),x.end() int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n;cin>>n; vector<pair<int,int>>v; int b[n]; for(int i=0;i<=n;i++){ int x;cin>>x; v.push_back({x,i}); } sort(all(v)); cin(b); sort(b,b+n); multiset<int>s; for(int i=0;i<n;i++){ // cout<<b[i]<<' '<<v[i].F<<el; s.insert(v[i].F-b[i]); } int ans[n+1]={}; ans[v[n].S]=*prev(s.end()); for(int i=n-1;i>=0;i--){ s.erase(s.find(v[i].F-b[i])); s.insert(v[i+1].F-b[i]); ans[v[i].S]=*prev(s.end()); } cout(ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...