답안 #586714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586714 2022-06-30T14:50:08 Z Vanilla Stove (JOI18_stove) C++17
100 / 100
52 ms 2772 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 2e5 + 2;

int main() {
	int n,k;
	cin >> n >> k;
	vector <int64> a (n);
	vector <int64> diff (n - 1);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (i != 0) diff[i-1] = a[i] - a[i-1] - 1;
	}
	int64 rs = a[n-1] - a[0] + 1;
	sort(diff.begin(), diff.end(), [] (int64 &a, int64 &b) {
		return a > b;
	});
	for (int i = 0; i < k - 1; i++){
		rs-=diff[i];
	}
	cout << rs << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 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 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 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 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 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 308 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 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 1 ms 212 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 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 308 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 44 ms 2748 KB Output is correct
17 Correct 45 ms 2760 KB Output is correct
18 Correct 52 ms 2744 KB Output is correct
19 Correct 43 ms 2772 KB Output is correct
20 Correct 42 ms 2764 KB Output is correct
21 Correct 42 ms 2764 KB Output is correct
22 Correct 43 ms 2752 KB Output is correct
23 Correct 42 ms 2740 KB Output is correct
24 Correct 43 ms 2736 KB Output is correct