# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
769342 |
2023-06-29T12:33:05 Z |
Mery2005 |
Stove (JOI18_stove) |
C++14 |
|
36 ms |
2376 KB |
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <unordered_map>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
const long long mod = 1e9+7;
const int N = 3e5+5;
int a[N] , dp[N];
void solve(){
int n , k;
cin >> n >> k;
for(int i = 1 ; i <= n ; i++){
cin >> a[i];
}
vector<int> v;
int start = a[1];
for(int i = 2 ; i <= n ; i++){
if(a[i] - start != 1){
v.push_back(a[i] - start - 1);
}
start = a[i];
}
sort(v.begin() , v.end());
int l = v.size();
long long int ans = n * 1ll;
for(int i = 0 ; i < (l-k + 1) ; i++){
ans += v[i] * 1ll;
}
cout << ans << endl;
}
int main(){
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
448 KB |
Output is correct |
12 |
Correct |
2 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
448 KB |
Output is correct |
12 |
Correct |
2 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
34 ms |
2260 KB |
Output is correct |
17 |
Correct |
34 ms |
2216 KB |
Output is correct |
18 |
Correct |
34 ms |
2256 KB |
Output is correct |
19 |
Correct |
34 ms |
2276 KB |
Output is correct |
20 |
Correct |
35 ms |
2188 KB |
Output is correct |
21 |
Correct |
34 ms |
2284 KB |
Output is correct |
22 |
Correct |
35 ms |
2376 KB |
Output is correct |
23 |
Correct |
34 ms |
2280 KB |
Output is correct |
24 |
Correct |
36 ms |
2236 KB |
Output is correct |