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;
#define mp make_pair
#define fr first
#define sc second
const long long inf=1e18;
long long a[100069];
void init(int n,vector<int> aa)
{
long long i;
for(i=1;i<=n;i++)
{
a[i]=aa[i-1];
}
}
int max_towers(int lb,int rb,int cw)
{
lb++;
rb++;
if(lb==rb)
{
return 1;
}
else
{
long long i,j,mn,mx,z=rb-lb+1;
for(i=lb;i<=rb;i++)
{
mn=inf;
mx=-inf;
for(j=i-1;j>=lb;j--)
{
if(a[j]<a[i])
{
break;
}
mx=max(mx,a[j]);
}
if(j>=lb)
{
mn=min(mn,mx);
}
mx=-inf;
for(j=i+1;j<=rb;j++)
{
if(a[j]<a[i])
{
break;
}
mx=max(mx,a[j]);
}
if(j<=rb)
{
mn=min(mn,mx);
}
if(mn-a[i]<cw)
{
z--;
}
}
return z;
}
}
# | 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... |