#include<bits/stdc++.h>
#include "towers.h"
using namespace std;
const int N=1e5;
int n,k,spe=-1;
vector<int>a;
void init(int N,vector<int>h){
n=N;
a=h;
bool ok=true;
for(int i=0;i<N;i++){
if((i==0||(i>0&&h[i-1]<h[i]))&&(i==n-1||(i<n-1&&h[i]>h[i+1]))){
spe=i;
for(int j=0;j<spe;j++){
if(h[j]>h[j+1]){
ok=false;
}
}
for(int i=spe+1;i<N;i++){
if(h[i-1]<h[i]){
ok=false;
}
}
if(ok==false){
spe=-1;
}
break;
}
}
}
int max_towers(int l,int r,int d){
if(spe>-1){
if(l==r){
return 1;
}
if(l<k&&k<r&&a[l]+d<=a[k]&&a[r]+d<=a[k]){
return 2;
}
else{
return 1;
}
}
int dp[n+5];
dp[l]=1;
for(int i=l+1;i<=r;i++){
dp[i]=1;
for(int j=i+2;i<=r;j++){
for(int k=i+1;k<j;k++){
if(a[i]+d<=a[k]&&a[j]+d<=a[j]){
dp[i]=max(dp[j]+1,dp[i]);
}
}
}
}
int ans=0;
for(int i=l;i<=r;i++){
ans=max(ans,dp[i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
211 ms |
968 KB |
12th lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
1352 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4043 ms |
464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
208 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
211 ms |
968 KB |
12th lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |