# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1005863 |
2024-06-23T07:19:53 Z |
Otalp |
Stove (JOI18_stove) |
C++14 |
|
59 ms |
6064 KB |
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n, k;
cin>>n>>k;
multiset<int> d;
k = min(k-1, n-1);
int mn=1e9, mx=0;
int ls = -1;
for(int i=1; i<=n; i++){
int x;
cin>>x;
mn = min(mn, x);
mx = max(mx, x);
if(ls != -1) d.insert(x - ls-1);
ls = x;
}
int ans = mx - mn + 1;
while(k--){
auto it = *d.rbegin();
ans -= it;
d.erase(d.find(it));
//cout<<it<<'\n';
}
cout<<ans;
}
int main(){
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
544 KB |
Output is correct |
11 |
Correct |
1 ms |
448 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
544 KB |
Output is correct |
11 |
Correct |
1 ms |
448 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
51 ms |
5972 KB |
Output is correct |
17 |
Correct |
47 ms |
6008 KB |
Output is correct |
18 |
Correct |
59 ms |
5972 KB |
Output is correct |
19 |
Correct |
52 ms |
6028 KB |
Output is correct |
20 |
Correct |
52 ms |
5968 KB |
Output is correct |
21 |
Correct |
51 ms |
6024 KB |
Output is correct |
22 |
Correct |
53 ms |
6064 KB |
Output is correct |
23 |
Correct |
52 ms |
5852 KB |
Output is correct |
24 |
Correct |
53 ms |
5912 KB |
Output is correct |