Submission #525786

# Submission time Handle Problem Language Result Execution time Memory
525786 2022-02-12T21:36:53 Z Hanksburger Stove (JOI18_stove) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
int a[100005];
vector<int> v;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k, ans;
	cin >> n >> k;
	for (int i=1; i<=n; i++)
		cin >> a[i];
	for (int i=1; i<n; i++)
		v.push_back(a[i+1]-a[i]-1);
	sort(v.begin(), v.end(), greater<int>());
	ans=a[n]-a[1]+1;
	for (int i=0; i<n-k; i++)
		ans-=v[i];
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -