Submission #931255

# Submission time Handle Problem Language Result Execution time Memory
931255 2024-02-21T13:05:43 Z ys2 Stove (JOI18_stove) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, k, prev, cur, ans;
vector <int> gaps;
signed main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cin>>n>>k;
	int prev=0;
	ans=n;
	for (int i=0; i<n; i++){
		int cur;
		cin>>cur;
		if ((cur-prev)!=1){
			//cout<<cur-prev<<'\n';
			gaps.push_back(cur-prev-1);
		}
		prev=cur;
	}
	int s=gaps.size();
	//cout<<s<<'s';
	sort(gaps.begin(), gaps.end());
	for (int i=0; i<s-k+1; i++){
		ans+=gaps[i];
	}
	cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 344 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 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -