Submission #1181123

#TimeUsernameProblemLanguageResultExecution timeMemory
1181123Born_To_LaughStove (JOI18_stove)C++17
50 / 100
132 ms327680 KiB
// Born_To_Laugh - Hughie Do #include <bits/stdc++.h> #define alle(sth) sth.begin(), sth.end() using namespace std; typedef long long ll; [[maybe_unused]] const ll MOD = 998244353, INF = 1e18 + 7; #define int ll void solve(){ int n, k;cin >> n >> k; vector<int> a(n+1, 0); for(int i=1; i<=n; ++i)cin >> a[i]; vector<vector<int>> dp(n+1, vector<int> (k+1, INF)); dp[0][0] = 0; for(int i=1; i<=n; ++i){ for(int j=1; j<=k; ++j){ dp[i][j] = min({ dp[i-1][j] + a[i] - a[i-1], dp[i-1][j-1] + 1 }); } } int ans = INF; for(int j=1; j<=k; ++j){ ans = min(ans, dp[n][j]); } cout << ans << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...