# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017502 |
2024-07-09T08:29:02 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
41 ms |
2260 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 , mn = mod;
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]);
mn = min(mn , a[i]);
}
mx++;
mx -= mn;
sort(v.begin() ,v.end() );
reverse(v.begin() , v.end() );
for(int i = 0; i < min(n - 1LL , k - 1LL); i++){
mx -= v[i] - 1;
}
cout << mx;
return 0;
}
//AZIM_BEST
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
30 ms |
2256 KB |
Output is correct |
17 |
Correct |
29 ms |
2256 KB |
Output is correct |
18 |
Correct |
41 ms |
2252 KB |
Output is correct |
19 |
Correct |
36 ms |
2112 KB |
Output is correct |
20 |
Correct |
29 ms |
2260 KB |
Output is correct |
21 |
Correct |
36 ms |
2260 KB |
Output is correct |
22 |
Correct |
29 ms |
2260 KB |
Output is correct |
23 |
Correct |
34 ms |
2260 KB |
Output is correct |
24 |
Correct |
29 ms |
2260 KB |
Output is correct |