# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
837198 |
2023-08-25T07:56:44 Z |
mngoc |
Stove (JOI18_stove) |
C++14 |
|
36 ms |
2028 KB |
#include<bits/stdc++.h>
#define forin(i,a,b) for(int i=a;i<=b;i++)
#define forde(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
using ll = long long;
const int N=1e5+10;
int a[N];
int tgc[N];
int n,k;
int main()
{
cin>>n>>k;
forin(i,1,n) cin>>a[i];
forin(i,2,n)
{
tgc[i-1]=a[i]-(a[i-1]+1);
}
sort(tgc+1,tgc+n);
//forin(i,1,n) cout<<tgc[i]<<" ";
ll res=0;
forin(i,1,n-k)
{
res+=tgc[i];
}
//cout<<res;
cout<<res+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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
34 ms |
1996 KB |
Output is correct |
17 |
Correct |
34 ms |
1996 KB |
Output is correct |
18 |
Correct |
36 ms |
2004 KB |
Output is correct |
19 |
Correct |
34 ms |
2004 KB |
Output is correct |
20 |
Correct |
34 ms |
2004 KB |
Output is correct |
21 |
Correct |
34 ms |
2004 KB |
Output is correct |
22 |
Correct |
34 ms |
1996 KB |
Output is correct |
23 |
Correct |
34 ms |
1936 KB |
Output is correct |
24 |
Correct |
34 ms |
2028 KB |
Output is correct |