Submission #1250159

#TimeUsernameProblemLanguageResultExecution timeMemory
1250159herominhsteveFinancial Report (JOI21_financial)C++20
14 / 100
4094 ms15428 KiB
#include <bits/stdc++.h>
using namespace std;

int N, D;
vector<int> A;
int ans = 0;

void dfs(int pos, int score, int max_so_far) {
    if (pos == N - 1) {
        if (A[pos] > max_so_far) score++;
        ans = max(ans, score);
        return;
    }

    // Try all next positions within D range
    for (int next = pos + 1; next <= min(N - 1, pos + D); ++next) {
        int new_score = score + (A[next] > max_so_far);
        dfs(next, new_score, max(max_so_far, A[next]));
    }
}

int main() {
    cin >> N >> D;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    // Try starting from any position i and ending at N-1
    for (int i = 0; i <= N - 1; ++i) {
        dfs(i, 1, A[i]); // Start with A[i] as first record
    }

    cout << ans << '\n';
    return 0;
}
#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...