# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
128219 |
2019-07-10T14:31:58 Z |
wasyl |
Stove (JOI18_stove) |
C++11 |
|
28 ms |
2424 KB |
#include <bits/stdc++.h>
using namespace std;
constexpr int nax = 1e5;
int n, k, tab[nax];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 0; i < n; ++i)
cin >> tab[i];
sort(tab, tab + n);
--k;
vector< int > ilo;
for (int i = 0; i < n - 1; ++i)
ilo.push_back(tab[i + 1] - tab[i] - 1);
sort(begin(ilo), end(ilo));
reverse(begin(ilo), end(ilo));
k = min(k, (int)ilo.size());
//cerr << tab[n - 1] + 1 << ' ' << tab[0] << ' ' << accumulate(ilo.end() - k, ilo.end(), 0) << '\n';
cout << tab[n - 1] + 1 - tab[0] - accumulate(ilo.begin(), ilo.begin() + k, 0) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
380 KB |
Output is correct |
12 |
Correct |
3 ms |
424 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
380 KB |
Output is correct |
12 |
Correct |
3 ms |
424 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
27 ms |
2424 KB |
Output is correct |
17 |
Correct |
27 ms |
2296 KB |
Output is correct |
18 |
Correct |
28 ms |
2424 KB |
Output is correct |
19 |
Correct |
27 ms |
2356 KB |
Output is correct |
20 |
Correct |
26 ms |
2296 KB |
Output is correct |
21 |
Correct |
27 ms |
2296 KB |
Output is correct |
22 |
Correct |
27 ms |
2300 KB |
Output is correct |
23 |
Correct |
27 ms |
2424 KB |
Output is correct |
24 |
Correct |
28 ms |
2424 KB |
Output is correct |