제출 #1257234

#제출 시각아이디문제언어결과실행 시간메모리
1257234mardaStove (JOI18_stove)C++20
0 / 100
0 ms324 KiB
#include<bits/stdc++.h>

#define endl "\n"
#define int long long int
#define pb push_back
#define mp make_pair
#define Bound 2e5 + 1
#define mid (l+r+1)/2

using namespace std;

void solve() {

    int n,k;
    cin >> n >> k;

    int* fuel = new int[k+1];

    int prev;
    cin >> prev;
    fuel[k] = 1;
    int nw;

    for(int i = 1; i < n; i++) {
        cin >> nw;

        for(int j = max(k-i,1LL); j < k; j++) {

            fuel[j] = min(fuel[j+1]+1, fuel[j]+nw-prev);

        }

        fuel[k] += nw-prev;

        prev = nw;
    }
    
    cout << fuel[1];



}

int32_t main() {

    cin.tie(0); cout.tie(0);
    //ios::sync_with_stdio(false);
    
    int t = 1; //cin >> t;

    while(t--) solve();

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...