Submission #97773

# Submission time Handle Problem Language Result Execution time Memory
97773 2019-02-18T12:31:21 Z Anai Stove (JOI18_stove) C++14
100 / 100
35 ms 2152 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> difs, v;
int ant, n, k;

int main() {
#ifdef HOME
	freopen("joi_stove.in", "r", stdin);
	freopen("joi_stove.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	difs.reserve(n - 1);
	sort(begin(v), end(v));
	for (int i = 1; i < n; ++i)
		difs.push_back(v[i] - v[i - 1] - 1);

	ant = n;
	sort(begin(difs), end(difs));
	for (int i = 0; i < n - k; ++i)
		ant+= difs[i];

	cout << ant << '\n';

	return 0; }
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 428 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 428 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 25 ms 2076 KB Output is correct
17 Correct 23 ms 2048 KB Output is correct
18 Correct 23 ms 2152 KB Output is correct
19 Correct 24 ms 2048 KB Output is correct
20 Correct 22 ms 2048 KB Output is correct
21 Correct 23 ms 2048 KB Output is correct
22 Correct 25 ms 2048 KB Output is correct
23 Correct 25 ms 2136 KB Output is correct
24 Correct 35 ms 2040 KB Output is correct