Submission #729491

#TimeUsernameProblemLanguageResultExecution timeMemory
729491BaytoroMeasures (CEOI22_measures)C++17
24 / 100
1561 ms5348 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll INF=1e18,mod=1e9+9,N=2e5+5; int d; int calc(vector<int> vec){ sort(all(vec)); int n=vec.size(); int l=-1,r=2e9; while(r-l>1){ int md=(l+r)/2; vector<int> a=vec; for(int i=0;i<n;i++){ if(!i){ a[i]-=md; continue; } int x=abs((a[i-1]+d)-a[i]); //cout<<x<<endl; if(x>md){ if(a[i]-md<a[i-1]+d) a[i]+=md; else a[i]-=md; } else{ if(a[i]-x<a[i-1]+d) a[i]+=x; else a[i]-=x; } /*cout<<md<<endl; for(auto it: a) cout<<it<<' '; cout<<endl;*/ } bool check=1; for(int i=1;i<n && check;i++) check&=(a[i]-a[i-1]>=d); if(check) r=md; else l=md; } return r; } vector<int> vec; void solve(){ int n,m;cin>>n>>m>>d; vec.resize(n); for(int i=0;i<n;i++){ cin>>vec[i]; } sort(all(vec)); int ans=0; for(int i=0;i<m;i++){ int x;cin>>x; auto it=lower_bound(all(vec),x); vec.insert(it,x); int cur=0; for(int i=(int)vec.size()-2;i>=0;i--){ int D=d-(vec[i+1]-vec[i]); cur=max(cur+D,0ll); ans=max(ans,cur); } cout<<ans/2; if(ans%2) cout<<".5"; cout<<' '; } } main(){ //fopn("friendcross"); ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); } }

Compilation message (stderr)

Main.cpp:77:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   77 | main(){
      | ^~~~
Main.cpp: In function 'void fopn(std::string)':
Main.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...