Submission #724033

#TimeUsernameProblemLanguageResultExecution timeMemory
724033groshiSwimming competition (LMIO18_plaukimo_varzybos)C++17
20 / 100
169 ms23252 KiB
#include<bits/stdc++.h> #define int long long using namespace std; vector<int> Q; int n,a,b; int mam[600000]; bool git(int x) { for(int i=0;i<=n;i++) mam[i]=0; int suma=1; mam[0]=1; int l=0,r=0; for(int i=1;i<=n;i++) { while(Q[l]+x<Q[i-1]) { suma-=mam[l]; l++; } while(Q[r]+x<Q[i-1]) { suma+=mam[r+1]; r++; } while(l+b<i) { suma-=mam[l]; l++; } while(r+a<i) { suma+=mam[r+1]; r++; } if(suma>0 && i-l>=a) mam[i]=1; } return mam[n]; } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int x; cin>>n>>a>>b; for(int i=1;i<=n;i++) { cin>>x; Q.push_back(x); } sort(Q.begin(),Q.end()); int pocz=0,kon=1e6,sre,ostd=1e9; while(pocz<kon) { sre=(pocz+kon)/2; if(git(sre)) { ostd=sre; kon=sre; } else pocz=sre+1; } cout<<ostd; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...