#include<bits/stdc++.h>
#include "towers.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int n;
vector<int>h;
vector<pair<int,int>>v;
vector<bool>used;
void init(int N,vector<int>H){
n=N; h=H;
used.resize(n);
for(int i=0;i<n;i++){
v.pb({H[i],i});
}
sort(all(h));
}
int max_towers(int L,int R,int D){
fill(all(used),0);
int ans=0;
for(auto [x,i]:v){
if(x<L||x>R) continue;
bool add=true;
int mx=0;
for(int j=i-1;j>=L;j--){
if(used[j]){
if(mx<x+D){
add=false;
}
}
mx=max(mx,h[j]);
}
mx=0;
for(int j=i+1;j<=R;j++){
if(used[j]){
if(mx<x+D){
add=false;
}
}
mx=max(mx,h[j]);
}
if(add){
ans++;
used[i]=true;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4005 ms |
1748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4016 ms |
2768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1633 ms |
1112 KB |
1st lines differ - on the 1st token, expected: '7197', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4005 ms |
1748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |