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>
#include "towers.h"
using namespace std;
const long long inf=1e18;
long long n,a[100069];
void init(int on,vector<int> aa)
{
long long i;
n=on;
for(i=1;i<=n;i++)
{
a[i]=aa[i-1];
}
}
int max_towers(int lb,int rb,int cw)
{
long long i,l=inf,c=0;
lb++;
rb++;
for(i=lb;i<=rb;i++)
{
if(c%2==0)
{
if(a[i]<=l-cw)
{
c++;
l=a[i];
}
else if(a[i]>l)
{
l=a[i];
}
}
else
{
if(a[i]>=l+cw)
{
c++;
l=a[i];
}
else if(a[i]<l)
{
l=a[i];
}
}
}
return (c+1)/2;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |