# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017479 |
2024-07-09T08:18:34 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
344 KB |
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
using namespace std;
#define int long long
int mod = 1e18 + 7;
signed main(){
int n , k , mx = 0;
cin >> n >> k;
int a[n];
vector <int> v;
for(int i = 0; i < n; i++){
cin >> a[i];
if(i != 0){
v.push_back(abs(a[i] - a[i - 1]));
}
mx = max(mx , a[i]);
}
if(k == n){
cout << n;
return 0;
}
if(k == 1){
cout << mx + 1;
return 0;
}
sort(v.begin() ,v.end() );
reverse(v.begin() , v.end() );
mx++;
int s = v.size();
for(int i = 0; i < min(s , k - 1LL); i++){
mx -= v[i] - 1;
}
cout << mx;
return 0;
}
//AZIM_BEST
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |