Submission #990582

# Submission time Handle Problem Language Result Execution time Memory
990582 2024-05-30T16:30:09 Z StuckOnA Stove (JOI18_stove) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n), vd(n - 1);
	for (int i = 0; i < n; i++) cin >> v[i];
	for (int i = 0; i < n - 1; i++)
		vd[i] = v[i + 1] - v[i] - 1;
	sort(vd.rbegin(), vd.rend());
	int sum = 0;
	for (int i = 0; i < k - 1; i++)
		sum += vd[i];
	cout << *max_element(v.begin(), v.end()) - sum << endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -