Submission #656999

# Submission time Handle Problem Language Result Execution time Memory
656999 2022-11-08T16:58:41 Z mdub Stove (JOI18_stove) C++14
100 / 100
58 ms 2036 KB
#include <bits/stdc++.h>

using namespace std;

int main () {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<int> espaces(n- 1);
	for (int i = 1; i < n; i++) {
		espaces[i-1] = a[i]-a[i- 1] - 1;
	}
	sort(espaces.begin(), espaces.end());
	int ans= a[n - 1]+1-a[0];
	for (int i = n - 2; i > n - 2 - (k -1); i--) {
		ans -= espaces[i];
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 2 ms 308 KB Output is correct
11 Correct 2 ms 336 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 308 KB Output is correct
16 Correct 58 ms 1996 KB Output is correct
17 Correct 47 ms 1952 KB Output is correct
18 Correct 45 ms 1964 KB Output is correct
19 Correct 44 ms 1964 KB Output is correct
20 Correct 45 ms 2036 KB Output is correct
21 Correct 44 ms 2032 KB Output is correct
22 Correct 44 ms 1960 KB Output is correct
23 Correct 47 ms 1960 KB Output is correct
24 Correct 44 ms 1956 KB Output is correct