Submission #988963

# Submission time Handle Problem Language Result Execution time Memory
988963 2024-05-27T06:11:23 Z Muhammet Stove (JOI18_stove) C++17
100 / 100
15 ms 2468 KB
#include <bits/stdc++.h>
using namespace std;

#define N 300005
#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second

int T, n, a[N], k;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);

	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	vector <int> v;
	for(int i = 1; i < n; i++){
		v.push_back(a[i+1]-a[i]-1);
	}
	sort(v.rbegin(), v.rend());
	int ans = n;
	k -= n;
	while(sz(v) > 0 and k < 0){
		k++;
		ans += v.back();
		v.pop_back();
	}
	cout << ans << '\n';
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 504 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 15 ms 2272 KB Output is correct
17 Correct 14 ms 2468 KB Output is correct
18 Correct 14 ms 2244 KB Output is correct
19 Correct 15 ms 2308 KB Output is correct
20 Correct 15 ms 2268 KB Output is correct
21 Correct 14 ms 2408 KB Output is correct
22 Correct 14 ms 2272 KB Output is correct
23 Correct 15 ms 2272 KB Output is correct
24 Correct 14 ms 2272 KB Output is correct