이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// In the name of Allah
#include <bits/stdc++.h>
#include "towers.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define Mp make_pair
#define pb push_back
#define endl '\n'
#define sep ' '
const int maxn = 1e5 + 7;
const ll oo = 1e9 + 7;
int n;
ll A[maxn];
int M[maxn], sm[maxn];
void init(int N, vector<int> H) {
n = N;
for (int i = 0; i < n; i++) A[i] = H[i];
for (int i = 1; i < n - 1; i++) {
if (A[i] < A[i - 1] && A[i] < A[i + 1]) M[i] = 1;
else M[i] = 0;
}
for (int i = 1; i <= n; i++) sm[i] = sm[i - 1] + M[i - 1];
}
int max_towers(int L, int R, int D) {
int res = sm[R + 1] - sm[L];
if (R - L + 1 == 1) {
if (M[L] == 0) res++;
}
else {
if (M[L] == 0 && A[L] < A[L + 1]) res++;
if (M[R] == 0 && A[R] < A[R - 1]) res++;
}
return res;
}
# | 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... |