# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
474704 |
2021-09-19T13:40:06 Z |
irmuun |
Stove (JOI18_stove) |
C++17 |
|
1 ms |
204 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll p[100001],a,b,ans,c,i;
vector<ll>v;
int main(){
cin>>a>>b;
for(i=1;i<=a;i++){
cin>>p[i];
if(i>1){
v.pb(p[i]-p[i-1]-1);
}
}
ans=p[a];
if(a<=b){
cout<<a<<endl;
v.clear();
}
else{
b--;
sort(v.begin(),v.end());
c=a-2;
for(i=1;i<=b;i++){
ans-=v[c];
c--;
}
cout<<ans<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |