답안 #466066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
466066 2021-08-17T16:14:53 Z fuad27 Stove (JOI18_stove) C++17
100 / 100
58 ms 2796 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main () {
	int n, k;
	cin >> n >> k;
	int t[n], d[n];
	for(int i = 0;i<n;i++) {
		cin >> t[i];
	}
	for(int i = 0;i<n-1;i++)d[i] = t[i+1] - t[i] - 1;
	int ans =t[n-1] - t[0] + 1;
	sort(d, d+n-1, greater<int>());
	for(int i = 1;i<k;i++)ans-=d[i-1];
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 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 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 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 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 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 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 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 2796 KB Output is correct
17 Correct 51 ms 2756 KB Output is correct
18 Correct 53 ms 2720 KB Output is correct
19 Correct 52 ms 2732 KB Output is correct
20 Correct 51 ms 2720 KB Output is correct
21 Correct 51 ms 2792 KB Output is correct
22 Correct 52 ms 2708 KB Output is correct
23 Correct 51 ms 2796 KB Output is correct
24 Correct 51 ms 2720 KB Output is correct