# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
474706 |
2021-09-19T13:44:37 Z |
irmuun |
Stove (JOI18_stove) |
C++17 |
|
66 ms |
3052 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]-p[1]+1;
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 |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
324 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
324 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
58 ms |
2980 KB |
Output is correct |
17 |
Correct |
54 ms |
2924 KB |
Output is correct |
18 |
Correct |
61 ms |
3052 KB |
Output is correct |
19 |
Correct |
52 ms |
2872 KB |
Output is correct |
20 |
Correct |
57 ms |
2856 KB |
Output is correct |
21 |
Correct |
66 ms |
2856 KB |
Output is correct |
22 |
Correct |
53 ms |
2872 KB |
Output is correct |
23 |
Correct |
55 ms |
2844 KB |
Output is correct |
24 |
Correct |
53 ms |
2896 KB |
Output is correct |