제출 #1247520

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

using namespace std;

#define ll long long
#define fi first
#define se second
#define pii pair<int, int>

const int MAX = 2e3 + 10;
int n;
int maxx;
int arr[MAX];
int dp[MAX];

void init(int N, std::vector<int> H) {
    n = N;

    maxx = 1;
    for (int i = 1; i <= n; i++) {
        if (H[i - 1] > H[maxx - 1]) maxx = i;
        arr[i] = H[i - 1];
    }
}

int max_towers(int lt, int rt, int d) {
    lt++, rt++;

    int sol = 0;
    for (int i = lt; i <= rt; i++) {
        dp[i] = 1;

        int maxx = 0;
        for (int j = i - 1; j >= lt; j--) {
            if (maxx - d >= arr[j] && maxx - d >= arr[i]) {
                dp[i] = max(dp[i], dp[j] + 1);
            }

            maxx = max(maxx, arr[j]);
        }

        sol = max(sol, dp[i]);
    }

    return sol;
}
#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...