# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42265 | RezwanArefin01 | Stove (JOI18_stove) | C++14 | 3 ms | 648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
vector<int> v;
for(int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if(i > 1) v.push_back(a[i - 1] - a[i]);
}
sort(v.begin(), v.end());
int ans = a[n] - a[1] + k;
for(int i = 0; i < k - 1; i++) ans += v[i];
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |