# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1033674 |
2024-07-25T04:13:15 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
19 ms |
2396 KB |
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
#include<bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define pll pair<long long, long long>
#define pii pair<int , int>
#define fi first
#define se second
#define bit(i,j) ((j >> i) & 1)
using namespace std;
const long long inf = 1e18+1;
const int mod = 1e9+7;
const int MAXN = 1e6+100;
#define int long long
int32_t main(){
//freopen("PAINT.INP", "r", stdin);
//freopen("PAINT.OUT", "w", stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
int n , k; cin >> n >> k;
vector<int> a(n+1) , v;
for(int i = 1 ; i <= n ; i++){
cin >> a[i];
if(i != 1) v.push_back(a[i] - a[i-1] - 1);
}
int sum = a[n] - a[1] + 1;
k--;
sort(all(v) , greater<int>());
for(int i = 0 ; i < k ; i++){
sum -= v[i];
}
cout << sum << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
1 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 |
348 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 |
1 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 |
1 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 |
348 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 |
1 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 |
1 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 |
17 ms |
2396 KB |
Output is correct |
17 |
Correct |
14 ms |
2268 KB |
Output is correct |
18 |
Correct |
13 ms |
2188 KB |
Output is correct |
19 |
Correct |
14 ms |
2268 KB |
Output is correct |
20 |
Correct |
19 ms |
2204 KB |
Output is correct |
21 |
Correct |
14 ms |
2268 KB |
Output is correct |
22 |
Correct |
14 ms |
2268 KB |
Output is correct |
23 |
Correct |
14 ms |
2364 KB |
Output is correct |
24 |
Correct |
14 ms |
2268 KB |
Output is correct |