답안 #91333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
91333 2018-12-27T07:33:24 Z aminra Stove (JOI18_stove) C++14
100 / 100
22 ms 10980 KB
//tavakol bar khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = (int)1e5 + 7;
const int MOD = (int)1e9 + 7;
const int infint = (int)1e8 + 3;
const ll inf = (ll)1e18;
int n, k, a[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++)	
		cin >> a[i];
	a[n] = a[n - 1];
	ll ans = k + a[n] - a[0];
	vector<ll> v;
	for (int i = 0; i < n; i++)
		v.push_back(a[i] - a[i + 1]);
	sort(v.begin(), v.end());
	for (int i = 0; i < k - 1; i++)
		ans += v[i];
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 472 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 472 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 664 KB Output is correct
10 Correct 2 ms 664 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 872 KB Output is correct
15 Correct 2 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 472 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 2 ms 528 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
9 Correct 2 ms 664 KB Output is correct
10 Correct 2 ms 664 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 2 ms 872 KB Output is correct
15 Correct 2 ms 912 KB Output is correct
16 Correct 20 ms 3248 KB Output is correct
17 Correct 21 ms 4204 KB Output is correct
18 Correct 21 ms 5192 KB Output is correct
19 Correct 21 ms 6156 KB Output is correct
20 Correct 21 ms 7120 KB Output is correct
21 Correct 21 ms 8092 KB Output is correct
22 Correct 21 ms 9048 KB Output is correct
23 Correct 22 ms 10012 KB Output is correct
24 Correct 22 ms 10980 KB Output is correct