#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "towers.h"
namespace TEST1 {
bool check(VI h) {
VI a;
a.pb(-1);
for (int x : h) a.pb(x);
a.pb(-1);
int cnt = 0;
replr(i, 1, a.size()-2) if (a[i] > a[i-1] && a[i] > a[i+1]) cnt++;
return cnt <= 1;
}
int mx = -1;
int mxv = -2e9;
int n;
VI h;
void init(int N, VI H) {
n = N;
h = H;
rep(i, n) if (h[i] > mxv) {
mx = i;
mxv = h[i];
}
}
int max_towers(int l, int r, int D) {
if (l < mx && mx < r) {
if (max(h[l], h[r]) + D <= mxv) return 2;
return 1;
}
return 1;
}
}
int test = -1;
void init(int N, VI H) {
if (TEST1::check(H)) {
TEST1::init(N, H);
test = 1;
}
}
int max_towers(int l, int r, int D) {
if (test == -1) return -1;
if (test == 1) return TEST1::max_towers(l, r, D);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
1492 KB |
Output is correct |
2 |
Correct |
605 ms |
2260 KB |
Output is correct |
3 |
Correct |
574 ms |
2260 KB |
Output is correct |
4 |
Correct |
631 ms |
2260 KB |
Output is correct |
5 |
Correct |
629 ms |
2260 KB |
Output is correct |
6 |
Correct |
612 ms |
2260 KB |
Output is correct |
7 |
Correct |
638 ms |
2260 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', 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: '-1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
430 ms |
2000 KB |
1st lines differ - on the 1st token, expected: '11903', found: '-1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
169 ms |
856 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: '-1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
274 ms |
1492 KB |
Output is correct |
2 |
Correct |
605 ms |
2260 KB |
Output is correct |
3 |
Correct |
574 ms |
2260 KB |
Output is correct |
4 |
Correct |
631 ms |
2260 KB |
Output is correct |
5 |
Correct |
629 ms |
2260 KB |
Output is correct |
6 |
Correct |
612 ms |
2260 KB |
Output is correct |
7 |
Correct |
638 ms |
2260 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '-1' |
12 |
Halted |
0 ms |
0 KB |
- |