Submission #159242

# Submission time Handle Problem Language Result Execution time Memory
159242 2019-10-21T15:18:42 Z socho Stove (JOI18_stove) C++14
100 / 100
88 ms 2184 KB
#include "bits/stdc++.h"
using namespace std;

int main() {
	
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i=0; i<n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr+n);
	int sm = arr[n-1] + 1 - arr[0];
	k--;
	int df[n-1];
	for (int i=0; i<n-1; i++) {
		df[i] = arr[i+1] - arr[i] - 1;
	}
	sort(df, df+n-1, greater<int>());
	for (int i=0; i<k; i++) {
		sm -= df[i];
	}
	
	cout << sm << endl;
	
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 84 ms 2040 KB Output is correct
17 Correct 85 ms 2140 KB Output is correct
18 Correct 85 ms 2040 KB Output is correct
19 Correct 85 ms 2100 KB Output is correct
20 Correct 85 ms 2184 KB Output is correct
21 Correct 85 ms 2028 KB Output is correct
22 Correct 85 ms 2092 KB Output is correct
23 Correct 88 ms 2168 KB Output is correct
24 Correct 88 ms 2108 KB Output is correct