# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
653412 |
2022-10-26T18:53:02 Z |
Dec0Dedd |
Stove (JOI18_stove) |
C++14 |
|
49 ms |
1816 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, l=-1; cin>>n>>k;
vector<int> v;
int ans=0, mn=1e9+1, mx=-1e9-1;
for (int i=1; i<=n; ++i) {
int a; cin>>a;
mn=min(mn, a), mx=max(mx, a);
if (l != -1) v.push_back(a-l-1);
l=a;
}
ans=mx-mn+1;
sort(v.begin(), v.end(), greater<int>());
for (int i=0; i<min((int)v.size(), k-1); ++i) ans-=v[i];
cout<<ans<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
316 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
316 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
308 KB |
Output is correct |
16 |
Correct |
47 ms |
1804 KB |
Output is correct |
17 |
Correct |
46 ms |
1736 KB |
Output is correct |
18 |
Correct |
46 ms |
1756 KB |
Output is correct |
19 |
Correct |
47 ms |
1736 KB |
Output is correct |
20 |
Correct |
49 ms |
1816 KB |
Output is correct |
21 |
Correct |
46 ms |
1796 KB |
Output is correct |
22 |
Correct |
46 ms |
1760 KB |
Output is correct |
23 |
Correct |
47 ms |
1788 KB |
Output is correct |
24 |
Correct |
46 ms |
1740 KB |
Output is correct |