# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
724037 | groshi | Swimming competition (LMIO18_plaukimo_varzybos) | C++17 | 419 ms | 22836 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> Q;
int n,a,b;
int mam[1200000];
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(l<Q.size() && Q[l]+x<Q[i-1])
{
suma-=mam[l];
l++;
}
while(r<Q.size() && 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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |