답안 #41205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41205 2018-02-14T01:06:36 Z MatheusLealV Stove (JOI18_stove) C++14
100 / 100
70 ms 2240 KB
#include <bits/stdc++.h>
#define N 100005
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n, k, v[N];

vector<ll> vet;

int main()
{
	cin>>n>>k;

	for(int i = 1; i <= n; i++) cin>>v[i];

	sort(v + 1, v + n + 1);

	for(int i = 1; i < n; i++) vet.push_back(v[i] - v[i + 1]);

	sort(vet.begin(), vet.end());

	ll ans = v[n] - v[1] + k;

	for(int i = 0; i < k - 1; i++) ans += vet[i];

	cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 1 ms 484 KB Output is correct
5 Correct 1 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 556 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 1 ms 484 KB Output is correct
5 Correct 1 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 556 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 4 ms 652 KB Output is correct
11 Correct 5 ms 652 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 3 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 1 ms 484 KB Output is correct
5 Correct 1 ms 496 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 556 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 4 ms 652 KB Output is correct
11 Correct 5 ms 652 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 3 ms 652 KB Output is correct
16 Correct 59 ms 2148 KB Output is correct
17 Correct 69 ms 2148 KB Output is correct
18 Correct 70 ms 2148 KB Output is correct
19 Correct 64 ms 2148 KB Output is correct
20 Correct 62 ms 2240 KB Output is correct
21 Correct 62 ms 2240 KB Output is correct
22 Correct 60 ms 2240 KB Output is correct
23 Correct 62 ms 2240 KB Output is correct
24 Correct 60 ms 2240 KB Output is correct