답안 #676535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676535 2022-12-31T08:16:41 Z abcdehello Stove (JOI18_stove) C++17
100 / 100
59 ms 2180 KB
#include <bits/stdc++.h>
using namespace std;
int n,k,t[100050],cnt,ans;
priority_queue<int,vector<int>,greater<int> > heap;
int main(){
	cin >> n >> k;
	cnt=ans=n;
	for (int i=1;i<=n;i++){
		cin >> t[i];
		if (i>1) heap.push(t[i]-t[i-1]-1);
	}
	while (cnt>k){
		int nxt=heap.top();
		heap.pop();
		cnt--;
		ans+=nxt;
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 304 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 0 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 304 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 0 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 304 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 0 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 308 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 47 ms 2064 KB Output is correct
17 Correct 48 ms 2056 KB Output is correct
18 Correct 51 ms 2112 KB Output is correct
19 Correct 59 ms 2180 KB Output is correct
20 Correct 44 ms 2080 KB Output is correct
21 Correct 39 ms 2072 KB Output is correct
22 Correct 38 ms 2132 KB Output is correct
23 Correct 39 ms 2144 KB Output is correct
24 Correct 44 ms 2112 KB Output is correct