Submission #41203

# Submission time Handle Problem Language Result Execution time Memory
41203 2018-02-14T01:04:40 Z MatheusLealV Stove (JOI18_stove) C++14
100 / 100
74 ms 11180 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";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 620 KB Output is correct
11 Correct 4 ms 652 KB Output is correct
12 Correct 3 ms 828 KB Output is correct
13 Correct 3 ms 828 KB Output is correct
14 Correct 3 ms 828 KB Output is correct
15 Correct 3 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 588 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 620 KB Output is correct
11 Correct 4 ms 652 KB Output is correct
12 Correct 3 ms 828 KB Output is correct
13 Correct 3 ms 828 KB Output is correct
14 Correct 3 ms 828 KB Output is correct
15 Correct 3 ms 876 KB Output is correct
16 Correct 60 ms 3336 KB Output is correct
17 Correct 73 ms 4300 KB Output is correct
18 Correct 56 ms 5312 KB Output is correct
19 Correct 58 ms 6232 KB Output is correct
20 Correct 56 ms 7196 KB Output is correct
21 Correct 56 ms 8160 KB Output is correct
22 Correct 60 ms 9124 KB Output is correct
23 Correct 74 ms 10216 KB Output is correct
24 Correct 59 ms 11180 KB Output is correct