# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
588299 |
2022-07-03T03:48:14 Z |
Spade1 |
Stove (JOI18_stove) |
C++14 |
|
1 ms |
212 KB |
#include<bits/stdc++.h>
//#include "grader.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
const int N = 1e5 + 10;
ll t[N];
void solve() {
int n, k; cin >> n >> k;
for (int i = 1; i <= n; ++i) cin >> t[i];
vector<ll> dif;
if (n == 1) {
cout << 1 << '\n';
return;
}
for (int i = 2; i <= n; ++i) {
dif.pb(t[i] - t[i-1] - 1);
}
sort(dif.begin(), dif.end(), greater<ll>());
ll sum = 0;
for (int i = 0; i < k-1; ++i) {
sum += dif[i];
}
cout << t[n] - sum << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |