# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
128218 |
2019-07-10T14:30:56 Z |
wasyl |
Stove (JOI18_stove) |
C++11 |
|
2 ms |
376 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 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |