이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |