Submission #42264

#TimeUsernameProblemLanguageResultExecution timeMemory
42264RezwanArefin01Stove (JOI18_stove)C++14
50 / 100
49 ms47724 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; int a[5001], n, K, dp[5001][5001]; int main(int argc, char const *argv[]) { scanf("%d %d", &n, &K); for(int i = 1; i <= n; i++) scanf("%d", &a[i]); for(int i = 1; i <= n; i++) dp[1][i] = a[i] - a[1] + 1; for(int k = 2; k <= K; k++) { int Min = 1e9; for(int i = 1; i <= n; i++) { dp[k][i] = a[i] + Min + 1; if(i < n) Min = min(Min, dp[k - 1][i] - a[i + 1]); } } cout << dp[K][n] << endl; }

Compilation message (stderr)

stove.cpp: In function 'int main(int, const char**)':
stove.cpp:10:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &K);
                        ^
stove.cpp:12:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...