Submission #72795

# Submission time Handle Problem Language Result Execution time Memory
72795 2018-08-27T00:54:13 Z Diuven Stove (JOI18_stove) C++14
100 / 100
43 ms 10640 KB
#include <bits/stdc++.h>
using namespace std;

int n,k,T[100010],ans;
vector<int> V;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>k;
	for(int i=1; i<=n; i++) cin>>T[i];
	sort(T+1, T+n+1);

	for(int i=1; i<=n; i++) if(T[i]!=T[i-1]) ans++;

	for(int i=1; i<n; i++)
		if(T[i+1]>T[i]+1) V.push_back(T[i+1]-T[i]-1);

	sort(V.begin(), V.end());

	for(int i=0; i<(int)V.size()-(k-1); i++) ans+=V[i];

	cout<<ans;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 3 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 3 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 6 ms 684 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 3 ms 952 KB Output is correct
14 Correct 4 ms 952 KB Output is correct
15 Correct 4 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 496 KB Output is correct
5 Correct 3 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 3 ms 524 KB Output is correct
8 Correct 2 ms 584 KB Output is correct
9 Correct 2 ms 648 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 6 ms 684 KB Output is correct
12 Correct 2 ms 860 KB Output is correct
13 Correct 3 ms 952 KB Output is correct
14 Correct 4 ms 952 KB Output is correct
15 Correct 4 ms 960 KB Output is correct
16 Correct 42 ms 2912 KB Output is correct
17 Correct 43 ms 3876 KB Output is correct
18 Correct 32 ms 4840 KB Output is correct
19 Correct 29 ms 5804 KB Output is correct
20 Correct 37 ms 6768 KB Output is correct
21 Correct 28 ms 7744 KB Output is correct
22 Correct 30 ms 8696 KB Output is correct
23 Correct 42 ms 9664 KB Output is correct
24 Correct 26 ms 10640 KB Output is correct