답안 #291601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291601 2020-09-05T14:23:46 Z reymontada61 Stove (JOI18_stove) C++14
100 / 100
98 ms 2384 KB
#include <bits/stdc++.h>
using namespace std;

const int MXN = 100005;

int n, k;
int t[MXN];

signed main() {

	cin >> n >> k;
	for (int i=0; i<n; i++) cin >> t[i];
	
	sort(t, t+n);
	
	int full = t[n-1] + 1 - t[0];
	
	k--;
	
	vector<int> gaps;
	
	for (int i=1; i<n; i++) {
		gaps.push_back(t[i] - t[i-1] - 1);
	}
	
	sort(gaps.begin(), gaps.end(), greater<int>());
	
	int ove = 0;
	
	for (int i=0; i<min((int) gaps.size(), k); i++) ove += gaps[i];
	
	cout << full - ove << endl;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 93 ms 2292 KB Output is correct
17 Correct 95 ms 2296 KB Output is correct
18 Correct 94 ms 2324 KB Output is correct
19 Correct 95 ms 2292 KB Output is correct
20 Correct 96 ms 2292 KB Output is correct
21 Correct 96 ms 2292 KB Output is correct
22 Correct 96 ms 2292 KB Output is correct
23 Correct 94 ms 2292 KB Output is correct
24 Correct 98 ms 2384 KB Output is correct