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 "towers.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second
int k, n; vi h;
vi cnt(1e5), pre(1e5);
void init(int N, vi H) {
n=N; h=H;
FOR(i,1,n-1){
if (H[i]>max(H[i-1],H[i+1])){
k=i; cnt[i]++;
}
}
pre[0]=cnt[0];
FOR(i,1,n) pre[i]=pre[i-1]+cnt[i];
}
int max_towers(int L, int R, int D) {
if (R-L<=1) return 1;
if (D==1){
return pre[R-1] - pre[L] + 1;
}
if (L>=k || R<=k) return 1;
if (max(h[L],h[R]) > h[k]-D) return 1;
return 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... |