# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100482 |
2024-10-14T04:28:21 Z |
crispxx |
Stove (JOI18_stove) |
C++14 |
|
18 ms |
3280 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vt vector
#define nl " \n"
#define pb emplace_back
#define all(x) x.begin(), x.end()
template <class _F, class _S>
void chmin(_F &a, _S b) {
if(a > b) a = b;
}
template <class _F, class _S>
void chmax(_F &a, _S b) {
if(a < b) a = b;
}
void run_case() {
int n, k;
cin >> n >> k;
vt<int> t(n);
vt<int> a;
for(int i = 0; i < n; i++) {
cin >> t[i];
}
for(int i = 0; i + 1 < n; i++) {
a.pb(t[i + 1] - t[i]);
}
int ans = t[n - 1] - t[0] + 1;
sort(all(a), greater<>());
for(int i = 0; i < k - 1; i++) {
ans -= a[i] - 1;
}
cout << ans << nl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt = 1;
// cin >> tt;
for(int i = 0; i < tt; i++) {
run_case();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
528 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
472 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
528 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
472 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
16 ms |
3280 KB |
Output is correct |
17 |
Correct |
15 ms |
3280 KB |
Output is correct |
18 |
Correct |
14 ms |
3280 KB |
Output is correct |
19 |
Correct |
15 ms |
3240 KB |
Output is correct |
20 |
Correct |
15 ms |
3280 KB |
Output is correct |
21 |
Correct |
15 ms |
3280 KB |
Output is correct |
22 |
Correct |
18 ms |
3152 KB |
Output is correct |
23 |
Correct |
16 ms |
3280 KB |
Output is correct |
24 |
Correct |
15 ms |
3280 KB |
Output is correct |