# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
535292 |
2022-03-10T00:38:47 Z |
Biaz |
Stove (JOI18_stove) |
C++17 |
|
58 ms |
2824 KB |
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define fi first
#define se second
#define ist insert
using namespace std;
typedef long long ll;
const int N=200005;
const int MOD=1000000007;//998244353
const int INF=2147483647;//1700000000000000000
int n,k;
int a[N];
int b[N];
inline void sol(){
cin >>n>>k;
for (int i=1;i<=n;i++)
cin >>a[i];
for (int i=1;i<n;i++)
b[i]=a[i+1]-a[i];
sort(b+1,b+n);
int ans=n;
for (int i=1;i<=n-k;i++)
ans+=b[i]-1;
cout <<ans<<'\n';
}
signed main(){
int _=1;
//cin >>_;
while (_--) sol();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
360 KB |
Output is correct |
11 |
Correct |
2 ms |
320 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
356 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
312 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
360 KB |
Output is correct |
11 |
Correct |
2 ms |
320 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
2 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
356 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
48 ms |
2824 KB |
Output is correct |
17 |
Correct |
43 ms |
2816 KB |
Output is correct |
18 |
Correct |
42 ms |
2704 KB |
Output is correct |
19 |
Correct |
44 ms |
2768 KB |
Output is correct |
20 |
Correct |
45 ms |
2824 KB |
Output is correct |
21 |
Correct |
46 ms |
2764 KB |
Output is correct |
22 |
Correct |
58 ms |
2720 KB |
Output is correct |
23 |
Correct |
48 ms |
2724 KB |
Output is correct |
24 |
Correct |
47 ms |
2708 KB |
Output is correct |