# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
502474 |
2022-01-06T05:24:33 Z |
zorianka |
Stove (JOI18_stove) |
C++17 |
|
62 ms |
1812 KB |
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
void solve() {
int n, k;
cin >> n >> k;
int ans = n;
int prev = 0;
vector<int> aboba;
for (int i = 0; i < n; i++) {
int ti;
cin >> ti;
if (prev != 0)
aboba.push_back(ti - prev - 1);
prev = ti;
}
sort(aboba.begin(), aboba.end());
for (int i = 0; i < n - k; i++)
ans += aboba[i];
cout << ans;
}
signed main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
292 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
304 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
292 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
304 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
332 KB |
Output is correct |
16 |
Correct |
62 ms |
1800 KB |
Output is correct |
17 |
Correct |
44 ms |
1752 KB |
Output is correct |
18 |
Correct |
44 ms |
1796 KB |
Output is correct |
19 |
Correct |
47 ms |
1728 KB |
Output is correct |
20 |
Correct |
48 ms |
1800 KB |
Output is correct |
21 |
Correct |
61 ms |
1680 KB |
Output is correct |
22 |
Correct |
51 ms |
1812 KB |
Output is correct |
23 |
Correct |
44 ms |
1772 KB |
Output is correct |
24 |
Correct |
44 ms |
1708 KB |
Output is correct |