Submission #740025

# Submission time Handle Problem Language Result Execution time Memory
740025 2023-05-12T00:56:15 Z mzv Stove (JOI18_stove) C++17
100 / 100
24 ms 2956 KB
#include <bits/stdc++.h>

#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

/* ------------------------ hi lol ------------------------ */

string s;
ll n,k,ans,arr[100'001];
priority_queue<ll> pq;

int main() {
	ccd
	cin >> n >> k;
	for (int i=1;i<=n;i++) {
		cin >> arr[i];
		if (i>1) {
			if (arr[i]-arr[i-1]>1) {
				pq.push(arr[i]-arr[i-1]-1);
			}
		}
	}
	ans=arr[n] - arr[1] + 1;
	k--;
//	cout << ans << endl;
//	while (!pq.empty()) {
//		cout << pq.top() << " ";
//		pq.pop();
//	} cout << endl;
	while (k&&!pq.empty()) {
		ans-= pq.top();
		pq.pop();
		k--;
	//	cout << ans << " ";
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 12 ms 2956 KB Output is correct
17 Correct 12 ms 2900 KB Output is correct
18 Correct 12 ms 2900 KB Output is correct
19 Correct 17 ms 2944 KB Output is correct
20 Correct 20 ms 2900 KB Output is correct
21 Correct 23 ms 2900 KB Output is correct
22 Correct 23 ms 2896 KB Output is correct
23 Correct 23 ms 2928 KB Output is correct
24 Correct 24 ms 2924 KB Output is correct