# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
884851 |
2023-12-08T14:48:58 Z |
Stiff |
Stove (JOI18_stove) |
C++17 |
|
40 ms |
2516 KB |
#include <bits/stdc++.h>
using namespace std;
vector<int> v, v2;
int n, k, ans;
int main() {
cin >> n >> k;
int a;
for (int i = 0; i < n; i++) {
cin>>a;
v.push_back(a);
}
for (int i = 1; i < n; i++) {
v2.push_back(v[i] - v[i - 1] - 1);
}
sort(v2.begin(), v2.end(), greater<int>());
ans = v.back() - v[0] + 1;
for (int i = 0; i < k - 1; i++) {
ans -= v2[i];
}
cout<<ans<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
440 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
40 ms |
2396 KB |
Output is correct |
17 |
Correct |
40 ms |
2512 KB |
Output is correct |
18 |
Correct |
39 ms |
2504 KB |
Output is correct |
19 |
Correct |
40 ms |
2516 KB |
Output is correct |
20 |
Correct |
40 ms |
2464 KB |
Output is correct |
21 |
Correct |
39 ms |
2472 KB |
Output is correct |
22 |
Correct |
40 ms |
2508 KB |
Output is correct |
23 |
Correct |
40 ms |
2512 KB |
Output is correct |
24 |
Correct |
40 ms |
2504 KB |
Output is correct |