#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long int
#define en cout << '\n'
#define pi pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
vector<int> A, B;
int n;
void init(int nn, std::vector<int> a) { n=nn;
if(n == 1) return;
A.pb(a[0]);
A.pb(a[1]);
B.pb(0);
B.pb(1);
for(int i = 2; i < n; ++i){
if(a[i] > A.back() && A.back() > A[int(A.size()) - 2]){
A.pop_back();
B.pop_back();
A.pb(a[i]);
B.pb(i);
}else if(a[i] < A.back() && A.back() < A[int(A.size()) - 2]){
A.pop_back();
B.pop_back();
A.pb(a[i]);
B.pb(i);
}
}
}
int max_towers(int L, int R, int D) {
if(n == 1) return 1;
int l = L, r = R;
L = lower_bound(all(B), L) - B.begin();
R = upper_bound(all(B), R) - B.begin(); --R;
// cout << "f";
if(R < L) return min(r-l+1, 2);
if(L == R) return min(r-l+1, 2);
if(A[L] > A[L + 1]) return (R-L+1)/2;
return (R-L+2)/2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
274 ms |
856 KB |
1st lines differ - on the 1st token, expected: '1', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
359 ms |
1080 KB |
1st lines differ - on the 1st token, expected: '11903', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
161 ms |
600 KB |
1st lines differ - on the 1st token, expected: '7197', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
274 ms |
856 KB |
1st lines differ - on the 1st token, expected: '1', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |