#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
int kval, k, n, premier, dernier;
set<pair<int, int>> avant;
set<pair<int, int>> apres;
void init(int tempn, vector<int> temph) {
n=tempn;
premier=temph[0], dernier=temph[n-1];
for (int i = 1; i < n; ++i)
{
if (temph[i]<temph[i-1])
{
kval=temph[i-1], k=i-1;
break;
}
avant.insert({temph[i-1], i-1});
}
for (int i = k+1; i < n; ++i)
{
apres.insert({temph[i], i});
}
return;
}
int max_towers(int L, int R, int D) {
if (kval-D<premier || kval-D<dernier || R-L<3) return 0;
auto itl=avant.lower_bound({kval-D, 0});
auto itr=apres.lower_bound({kval-D, 0});
if (itl==avant.end() || itr==apres.end()) itl--, itr--;
auto a=*itl, b=*itr;
int l=a.second, r=b.second;
if (l<L || r>R || k>R || k<L) return 0;
return (l-L+1)*(R-r+1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
375 ms |
3448 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 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 |
208 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 |
481 ms |
5652 KB |
1st lines differ - on the 1st token, expected: '11903', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
200 ms |
1488 KB |
1st lines differ - on the 1st token, expected: '7197', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 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 |
375 ms |
3448 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |