답안 #466058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
466058 2021-08-17T16:03:29 Z fuad27 Stove (JOI18_stove) C++17
20 / 100
2 ms 332 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main () {
	int n, k;
	cin >> n >> k;
	int t[n+1], d[n];
	t[0] = 0;
	for(int i = 1;i<=n;i++) {
		cin >> t[i];
		d[i-1ll] = t[i] - t[i-1] - 1ll;
	}
	int Max = t[n]+1ll, Min = t[1];
	int ans = Max - Min;
	sort(d, d+n);
	reverse(d, d+n);
	for(int i = 0;i<min(n, k-1ll);i++)ans-=d[i];
	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 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 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 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 Incorrect 2 ms 332 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 Incorrect 2 ms 332 KB Output isn't correct
13 Halted 0 ms 0 KB -