Submission #1179327

#TimeUsernameProblemLanguageResultExecution timeMemory
1179327shirokitoStove (JOI18_stove)C++20
20 / 100
1102 ms198044 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define el '\n' const int N = 5000 + 24; int n, k; ll a[N], dp[N][N]; void solve() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { for (int i2 = 1; i2 <= i; i2++) { dp[i][j] = min(dp[i][j], dp[i2 - 1][j - 1] + (a[i] - a[i2] + 1)); } } } cout << dp[n][k] << el; } signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "file" if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int T = 1; // cin >> T; while (T--) solve(); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...