Submission #762788

# Submission time Handle Problem Language Result Execution time Memory
762788 2023-06-21T19:04:07 Z MSK17 Stove (JOI18_stove) C++14
100 / 100
37 ms 2036 KB
#include <bits/stdc++.h>
 
int main(){
	int n,k;
	std::cin>>n>>k;
	std::vector<int> t(n), diff(n-1);
	for(int i{}; i < n; ++i)
		std::cin>>t[i];
	std::sort(t.begin(), t.end());
	for(int i{}; i < n-1; ++i)
		diff[i]=t[i+1]-t[i]-1;
	std::sort(diff.begin(), diff.end());
	long long ans{n};
	for(int i{}; i < n-k; ++i)
		ans+=diff[i];
	std::cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 308 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 308 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 37 ms 1968 KB Output is correct
17 Correct 36 ms 1968 KB Output is correct
18 Correct 37 ms 2036 KB Output is correct
19 Correct 36 ms 1964 KB Output is correct
20 Correct 36 ms 2036 KB Output is correct
21 Correct 35 ms 1968 KB Output is correct
22 Correct 35 ms 1980 KB Output is correct
23 Correct 35 ms 1968 KB Output is correct
24 Correct 34 ms 1996 KB Output is correct