제출 #1233937

#제출 시각아이디문제언어결과실행 시간메모리
1233937antonn송신탑 (IOI22_towers)C++20
0 / 100
4056 ms1572 KiB
#include "towers.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;

int n, a[N];

void init(int N, vector<int> h) {
    n = N;
    for (int i = 1; i <= n; ++i) a[i] = h[i - 1];
}

int max_towers(int l, int r, int d) {
    ++l;
    ++r;
    
    int res = 0;
    for (int pos = l; pos <= r; ++pos) {
        int cnt = 1;
        int j = pos - 1, last = pos, mx = 0;
        while (j >= l) {
            if (a[j] <= mx - d && a[last] <= mx - d) {
                last = j;
                mx = 0;
                cnt++;
            } else {
                mx = max(mx, a[j]);
            }
            --j;
        }
        j = pos + 1;
        last = pos;
        mx = 0;
        while (j <= r) {
            if (a[j] <= mx - d && a[last] <= mx - d) {
                last = j;
                mx = 0;
                cnt++;
            } else {
                mx = max(mx, a[j]);
            }
            ++j;
        }
        res = max(res, cnt);
    }
    return res;
}


#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...