Submission #86597

# Submission time Handle Problem Language Result Execution time Memory
86597 2018-11-26T21:33:47 Z KCSC Stove (JOI18_stove) C++14
0 / 100
2 ms 376 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 = n - 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 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -