제출 #1221945

#제출 시각아이디문제언어결과실행 시간메모리
1221945spetrFinancial Report (JOI21_financial)C++20
28 / 100
4104 ms1114112 KiB
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

#define ll long long
const ll mmod = 998244353;  
#define vl vector<long long>
#define vll vector<vector<long long>>

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, d;
    cin >> n >> d;

    vl nums;
    for (ll i = 0; i < n; i++){
        ll num;
        cin >> num;
        nums.push_back(num);
    }

    vll dp(n+1, vl(n, 10e12));
    for(ll i = 0; i < n; i++)
        dp[1][i] = nums[i];

    for(ll i = 0; i < n; i++){
        for(ll k = 2; k <= n; k++){
            ll best = 10e12;
            ll nula = 0;
            ll lo = max(nula, i - d);
            for(ll t = lo; t < i; t++){
                best = min(best, dp[k][t]);
            }
            best = max(best, nums[i]);
            for(ll t = lo; t < i; t++){
                if (dp[k-1][t] < nums[i])
                    best = min(best, nums[i]);
            }
            dp[k][i] = best;
        }
    }

    ll skore = 1;
    for(ll k = 1; k <= n; k++){
        if (dp[k][n-1] < 10e12)
            skore = k;
    }
    cout << skore << "\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...