제출 #1257542

#제출 시각아이디문제언어결과실행 시간메모리
1257542mardaStove (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]; for(int i = 0; i < k+1; i++) fuel[i] = 0; int prev; cin >> prev; fuel[1] = 1; int nw; for(int i = 1; i < n; i++) { cin >> nw; for(int j = min(i+1,k); j > 1; j--) { fuel[j] = min(fuel[j-1]+1, fuel[j]+nw-prev); } fuel[1] += nw-prev; prev = nw; } cout << fuel[k]; } 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...