# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
81937 |
2018-10-28T01:43:45 Z |
mra2322001 |
Stove (JOI18_stove) |
C++14 |
|
29 ms |
10240 KB |
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)
using namespace std;
typedef long long ll;
const int N = 100002;
int n, a[N], b[N], k;
int main(){
ios_base::sync_with_stdio(0);
cin >> n >> k;
f1(i, n) cin >> a[i];
if(k==n){
cout << n; return 0;
}
f1(i, n - 1){
b[i] = a[i + 1] - a[i] - 1;
}
int res = a[n] - a[1] + 1;
sort(b + 1, b + n + 1);
for(int i = n; i >= n - k + 2; i--){
res = res - b[i];
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
572 KB |
Output is correct |
8 |
Correct |
2 ms |
572 KB |
Output is correct |
9 |
Correct |
2 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
572 KB |
Output is correct |
8 |
Correct |
2 ms |
572 KB |
Output is correct |
9 |
Correct |
2 ms |
612 KB |
Output is correct |
10 |
Correct |
3 ms |
612 KB |
Output is correct |
11 |
Correct |
4 ms |
684 KB |
Output is correct |
12 |
Correct |
3 ms |
732 KB |
Output is correct |
13 |
Correct |
4 ms |
764 KB |
Output is correct |
14 |
Correct |
3 ms |
796 KB |
Output is correct |
15 |
Correct |
2 ms |
832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
572 KB |
Output is correct |
8 |
Correct |
2 ms |
572 KB |
Output is correct |
9 |
Correct |
2 ms |
612 KB |
Output is correct |
10 |
Correct |
3 ms |
612 KB |
Output is correct |
11 |
Correct |
4 ms |
684 KB |
Output is correct |
12 |
Correct |
3 ms |
732 KB |
Output is correct |
13 |
Correct |
4 ms |
764 KB |
Output is correct |
14 |
Correct |
3 ms |
796 KB |
Output is correct |
15 |
Correct |
2 ms |
832 KB |
Output is correct |
16 |
Correct |
25 ms |
2528 KB |
Output is correct |
17 |
Correct |
29 ms |
3492 KB |
Output is correct |
18 |
Correct |
28 ms |
4456 KB |
Output is correct |
19 |
Correct |
25 ms |
5580 KB |
Output is correct |
20 |
Correct |
24 ms |
6512 KB |
Output is correct |
21 |
Correct |
25 ms |
7344 KB |
Output is correct |
22 |
Correct |
24 ms |
8340 KB |
Output is correct |
23 |
Correct |
27 ms |
9404 KB |
Output is correct |
24 |
Correct |
23 ms |
10240 KB |
Output is correct |