# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
678029 |
2023-01-05T04:17:24 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
212 KB |
#include <bits/stdc++.h>
#define len(x) (int)x.size()
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5 + 5;
vector <int> v;
int n,k,a[N];
ll cnt;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i=1;i<=n;i++){
cin >> a[i];
}
k--;
for (int i=2;i<=n;i++){
v.pb(a[i] - (a[i-1] + 1));
}
sort(v.begin(), v.end(), greater<int>());
for (int i=0;i<k;i++){
cnt+=v[i];
}
cout << a[n] - cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 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 |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |