# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
922016 |
2024-02-04T18:08:52 Z |
406 |
Stove (JOI18_stove) |
C++17 |
|
16 ms |
2388 KB |
#include <bits/stdc++.h>
#define int int64_t
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ar = array<int, 2>;
const int64_t INF = 1ll << 60;
const int N = 2e5 + 5;
int n, a[N], k;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
if (n == 1) {
cout << 1;
return 0;
}
FOR(i, 0, n) cin >> a[i];
for (int i = n - 1; i >= 1; --i)
a[i] -= a[i - 1] + 1;
sort(a + 1, a + n);
int x = n;
FOR(i, 1, n - k + 1) x += a[i];
cout << x << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
400 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
400 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
476 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
472 KB |
Output is correct |
14 |
Correct |
1 ms |
476 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
400 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
476 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
472 KB |
Output is correct |
14 |
Correct |
1 ms |
476 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
14 ms |
2140 KB |
Output is correct |
17 |
Correct |
14 ms |
2128 KB |
Output is correct |
18 |
Correct |
14 ms |
2084 KB |
Output is correct |
19 |
Correct |
14 ms |
2100 KB |
Output is correct |
20 |
Correct |
14 ms |
2136 KB |
Output is correct |
21 |
Correct |
14 ms |
2140 KB |
Output is correct |
22 |
Correct |
14 ms |
2212 KB |
Output is correct |
23 |
Correct |
14 ms |
2388 KB |
Output is correct |
24 |
Correct |
16 ms |
2140 KB |
Output is correct |