제출 #628552

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6285522022-08-13 13:21:40dqhungdl송신탑 (IOI22_towers)C++17
15 / 100
4059 ms9296 KiB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int N, maxH[MAX][20];
bool isMountain = true;
vector<int> H;
int get(int l, int r) {
int k = log2(r - l + 1);
return max(maxH[l][k], maxH[r - (1 << k) + 1][k]);
}
void init(int _N, vector<int> _H) {
N = _N, H = _H;
for (int i = 0; i < N; i++)
maxH[i][0] = H[i];
for (int t = 1; t <= 18; t++)
for (int i = 0; i + (1 << t) - 1 < N; i++)
maxH[i][t] = max(maxH[i][t - 1], maxH[i + (1 << (t - 1))][t - 1]);
int id = max_element(H.begin(), H.end()) - H.begin();
for (int i = id; i > 0 && isMountain; i--)
isMountain &= (H[i] > H[i - 1]);
for (int i = id; i < N - 1 && isMountain; i++)
isMountain &= (H[i] > H[i + 1]);
}
int max_towers(int L, int R, int D) {
if (isMountain)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...