이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
ll n, k;
vll ve;
void init (int n, vi ve) {
::n = n;
k = 0;
::ve = vll(ve.begin(), ve.end());
while (ve[k] < ve[k+1]) k++;
}
const ll MAXN = 2E3+16;
ll dp[MAXN];
int max_towers (int ql, int qr, int d) {
fill(dp+ql, dp+qr+1, 0);
for (ll i = ql; i <= qr; i++) {
ll maxN = 0;
dp[i] = 1;
for (ll j = i-1; j >= ql; j--) {
if (max(ve[i], ve[j]) <= maxN-d) dp[i] = max(dp[i], dp[j]+1);
maxN = max(maxN, ve[j]);
}
}
return *max_element(dp+ql, dp+qr+1);
}
# | 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... |