답안 #868259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868259 2023-10-31T01:44:21 Z TheLostSun Stove (JOI18_stove) C++14
100 / 100
17 ms 2376 KB
/*
   _____       __                       ___    __   _            
  / ___/____  / /________ _            /   |  / /__(_)___  ____ _
  \__ \/ __ \/ / ___/ __ `/  ______   / /| | / //_/ / __ \/ __ `/
 ___/ / /_/ / / /  / /_/ /  /_____/  / ___ |/ ,< / / / / / /_/ / 
/____/\____/_/_/   \__,_/           /_/  |_/_/|_/_/_/ /_/\__,_/  
                                                                 
*/

#include <bits/stdc++.h>

using namespace std;

int n,k;
int a[100001];
vector<int> ve;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int res = a[n] - a[1] + 1;
	int tru = 0;
	for (int i = 1; i <= n - 1; i++) ve.push_back(a[i + 1] - (a[i] + 1));
	sort(ve.begin(), ve.end());
	k--;
	for (int i = ve.size() - 1; i >= 0; i--)
	{
		if (k == 0) break;
		k--;
		tru += ve[i];
	};
	cerr << res << " " << tru << '\n';
	cout << res - tru;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 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 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 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 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 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 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 17 ms 2272 KB Output is correct
17 Correct 17 ms 2268 KB Output is correct
18 Correct 14 ms 2272 KB Output is correct
19 Correct 15 ms 2376 KB Output is correct
20 Correct 14 ms 2268 KB Output is correct
21 Correct 15 ms 2236 KB Output is correct
22 Correct 15 ms 2272 KB Output is correct
23 Correct 14 ms 2272 KB Output is correct
24 Correct 14 ms 2364 KB Output is correct