Submission #86598

# Submission time Handle Problem Language Result Execution time Memory
86598 2018-11-26T21:35:47 Z KCSC Stove (JOI18_stove) C++14
100 / 100
82 ms 10408 KB
#include <bits/stdc++.h>
using namespace std;

const int DIM = 100005;

int lst[DIM], arr[DIM];

int main(void) {
#ifdef HOME
	freopen("stove.in", "r", stdin);
	freopen("stove.out", "w", stdout); 
#endif
	int n, k; cin >> n >> k; --k;
	for (int i = 1; i <= n; ++i) {
		cin >> arr[i]; 
		if (i > 1) {
			lst[i - 1] = arr[i] - arr[i - 1] - 1; } }
	sort(lst + 1, lst + n, greater<int>()); 
	int ans = arr[n] - arr[1] + 1;
	for (int i = 1; i <= k; ++i) {
		ans -= lst[i]; }
	cout << ans;
	return 0; }
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 664 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 2 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 664 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 2 ms 664 KB Output is correct
10 Correct 4 ms 664 KB Output is correct
11 Correct 4 ms 668 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 4 ms 748 KB Output is correct
14 Correct 3 ms 780 KB Output is correct
15 Correct 4 ms 812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 664 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 2 ms 664 KB Output is correct
10 Correct 4 ms 664 KB Output is correct
11 Correct 4 ms 668 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 4 ms 748 KB Output is correct
14 Correct 3 ms 780 KB Output is correct
15 Correct 4 ms 812 KB Output is correct
16 Correct 76 ms 2528 KB Output is correct
17 Correct 58 ms 3504 KB Output is correct
18 Correct 62 ms 4428 KB Output is correct
19 Correct 76 ms 5384 KB Output is correct
20 Correct 61 ms 6416 KB Output is correct
21 Correct 62 ms 7448 KB Output is correct
22 Correct 82 ms 8340 KB Output is correct
23 Correct 59 ms 9316 KB Output is correct
24 Correct 58 ms 10408 KB Output is correct