답안 #404864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
404864 2021-05-15T07:49:19 Z ahmeteren Stove (JOI18_stove) C++14
100 / 100
63 ms 2320 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k, sil = 0;
	cin >> n >> k;
	vector<int> vec(n), a;
	for(int i = 0; i < n; i++)
	{
		cin >> vec[i];
		if(i > 0)
			a.push_back(vec[i] - vec[i-1] - 1);
	}
	sort(a.rbegin(), a.rend());
	for(int i = 0; i < k-1; i++)
	{
		sil += a[i];
	}
	cout << vec[n-1] + 1 - vec[0] - sil << endl;
	return 0;;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 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 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 352 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 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 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 352 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 63 ms 2132 KB Output is correct
17 Correct 52 ms 2112 KB Output is correct
18 Correct 52 ms 2108 KB Output is correct
19 Correct 52 ms 2156 KB Output is correct
20 Correct 52 ms 2152 KB Output is correct
21 Correct 53 ms 2320 KB Output is correct
22 Correct 52 ms 2108 KB Output is correct
23 Correct 62 ms 2188 KB Output is correct
24 Correct 56 ms 2188 KB Output is correct