Submission #545335

#TimeUsernameProblemLanguageResultExecution timeMemory
545335AktanJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
319 ms21708 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>; #define int long long #define ft first #define sc second const int mod=1e9+7,INF=1e17,N=2e5+10; vector<pair<int,int>> v; multiset<int> s; int ans[N]; main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin >> n; vector<int> a,b; for(int i=1;i<=n+1;i++){ int x; cin >> x; v.push_back({x,i}); } for(int i=1;i<=n;i++){ int x; cin >> x; b.push_back(x); } sort(v.begin(),v.end()); sort(b.begin(),b.end()); int mn=INF; for(int i=0;i<n;i++){ s.insert(max(0ll,v[i+1].ft-b[i])); } ans[v[0].sc]=*--s.end(); for(int i=1;i<=n;i++){ s.erase(s.find(max(0ll,v[i].ft-b[i-1]))); s.insert(max(0ll,v[i-1].ft-b[i-1])); ans[v[i].sc]=*--s.end(); } for(int i=1;i<=n+1;i++){ cout << ans[i] << " "; } }

Compilation message (stderr)

ho_t1.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:33:6: warning: unused variable 'mn' [-Wunused-variable]
   33 |  int mn=INF;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...