답안 #468581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468581 2021-08-28T20:29:40 Z PiejanVDC Stove (JOI18_stove) C++17
100 / 100
59 ms 1868 KB
#include <bits/stdc++.h>
using namespace std;

signed main() {
	int n,k; cin>>n>>k;
	int prev; cin>>prev;
	priority_queue<int>pq;
	for(int i = 1 ; i < n ; i++) {
		int x; cin>>x;
		pq.push(-x+prev+1);
		prev=x;
	}
	int ans=n;
	while(n > k) {
		ans+=-(pq.top());
		pq.pop();
		n--;
	}
	cout << ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 58 ms 1736 KB Output is correct
17 Correct 57 ms 1792 KB Output is correct
18 Correct 57 ms 1728 KB Output is correct
19 Correct 59 ms 1868 KB Output is correct
20 Correct 52 ms 1688 KB Output is correct
21 Correct 52 ms 1696 KB Output is correct
22 Correct 45 ms 1728 KB Output is correct
23 Correct 45 ms 1768 KB Output is correct
24 Correct 45 ms 1736 KB Output is correct