# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
678035 |
2023-01-05T04:56:23 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
212 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
void solve() {
ll n, k;
cin >> n >> k;
if(k == n) {
cout << n << '\n';
return;
}
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
vector <ll> v;
for(int i = 2; i <= n; i++) {
v.push_back(a[i] - a[i - 1] + 1);
}
sort(v.begin(), v.end());
ll sum = 0;
for(int i = 0; i < n - k; i++) {
sum += v[i];
}
cout << sum << '\n';
}
int main() {
//freopen("success.in", "r", stdin);
//freopen("success.out", "w", stdout);
ll t = 1;
//cin >> t;
while(t--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |