답안 #419848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419848 2021-06-07T14:00:03 Z schse Financial Report (JOI21_financial) C++17
0 / 100
587 ms 512612 KB
#include <bits/stdc++.h>
using namespace std;

int N, D;
vector<int> arr;
vector<vector<int>> dp = vector<vector<int>>(8000, vector<int>(8000, -1));

int rec(int n, int cmax = -1)
{
    int score = arr[n] > cmax ? 1 : 0;
    int tmp = 0;
    int cmal = cmax;

    if (cmax != -1 && dp[n][cmax] != -1)
        return dp[n][cmax];

    if (n == N - 1)
        return dp[n][cmax] = score;

    cmax = max(cmax, arr[n]);
    for (int i = 1; i <= D && i + n <= N - 1; i++)
        tmp = max(tmp, rec(n + i, cmax));
    if (cmal != -1)
        return dp[n][cmal] = score + tmp;
    return score + tmp;
}

int main()
{
    cin >> N >> D;
    arr.resize(N);
    for (int &i : arr)
        cin >> i;

    {
        vector<int> arr2 = arr;
        sort(arr2.begin(), arr2.end());
        map<int, int> copr;
        int c = 1;
        copr[arr2[0]] = ++c;
        for (int i = 1; i < N; i++)
            if (arr2[i - 1] < arr2[i])
                copr[arr2[i]] = ++c;
        for (int &i : arr)
            i = copr[i];
    }

    int score = 0;
    for (int i = 0; i < N; i++)
        score = max(score, rec(i));
    cout << score;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 414 ms 508992 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 414 ms 508992 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 414 ms 508992 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 550 ms 512520 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 587 ms 512612 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 414 ms 508992 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -