# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
647150 |
2022-10-01T16:50:42 Z |
danikoynov |
Stove (JOI18_stove) |
C++14 |
|
1 ms |
212 KB |
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 1e5 + 10;
int n, k, t[maxn], d[maxn];
void solve()
{
cin >> n >> k;
for (int i = 1; i <= n; i ++)
cin >> t[i], d[i - 1] = t[i] - t[i - 1] - 1;
sort(d + 1, d + n);
int ans = t[n];
for (int i = n - 1; i > n - k; i --)
ans -= d[i];
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |