답안 #891878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891878 2023-12-24T10:33:52 Z goodspeed0208 Stove (JOI18_stove) C++14
100 / 100
34 ms 2940 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<utility>
#define int long long
#define INF 1000000000000000000
using namespace std;

signed main() {
	int n, k;
	cin >> n >> k;
	vector<int>v(n);
	for (auto &i : v) cin >> i;
	vector<int>d(n-1);
	for (int i = 0 ; i < n-1 ; i++) {
		d[i] = v[i+1] - v[i];
	}
	sort(d.begin(), d.end());
	int ans = n;
	for (int i = 0 ; i < n-k ; i++) {
		ans += d[i]-1;
	}
	cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 432 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 356 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 356 KB Output is correct
16 Correct 34 ms 2900 KB Output is correct
17 Correct 34 ms 2908 KB Output is correct
18 Correct 34 ms 2752 KB Output is correct
19 Correct 34 ms 2940 KB Output is correct
20 Correct 34 ms 2900 KB Output is correct
21 Correct 34 ms 2904 KB Output is correct
22 Correct 33 ms 2740 KB Output is correct
23 Correct 34 ms 2872 KB Output is correct
24 Correct 34 ms 2896 KB Output is correct