이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;
int n,h[MAXN],maxh;
int dp[MAXN],ans;
void init(int N,vector<int> H){
n=N;
for(int i=1;i<=n;i++){
h[i]=H[i-1];
}
}
int max_towers(int L, int R, int D){
ans=0; L++; R++;
for(int i=L;i<=R;i++){
maxh=0; dp[i]=1;
for(int f=i-1;f>=L;f--){
if(h[f]<=maxh-D and h[i]<=maxh-D){
dp[i]=max(dp[i],dp[f]+1);
}
maxh=max(maxh,h[f]);
}
ans=max(ans,dp[i]);
}
return ans;
}
/*
int main(){
init(7, {10, 20, 60, 40, 50, 30, 70});
cout<<max_towers(1,5,10)<<"\n";
cout<<max_towers(0, 6, 17)<<"\n";
}
*/
# | 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... |