# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
994550 |
2024-06-07T21:30:27 Z |
APROHACK |
Stove (JOI18_stove) |
C++17 |
|
16 ms |
2432 KB |
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
ll n, k;
vector<int>t;
vector<int>restas;
void tc(){
cin >> n >> k;
for(int i = 0 ; i < n ; i ++){
int temp;
cin >> temp;
if(i > 0)restas.pb(temp - t.back() - 1);
t.pb(temp);
}
sort(restas.begin(), restas.end());
int total = t.back() + 1 - t[0];
for(int i = 0 ; i < k - 1 ; i ++){
if(!restas.empty()){
total -= restas.back();
restas.pop_back();
}
}
cout << total << "\n";
}
void end_tc(){
}
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(NULL);
int t = 1;
while(t--){
tc();
end_tc();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
376 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 |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
376 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 |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
512 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 |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
376 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 |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
512 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 |
15 ms |
2264 KB |
Output is correct |
17 |
Correct |
13 ms |
2264 KB |
Output is correct |
18 |
Correct |
14 ms |
2432 KB |
Output is correct |
19 |
Correct |
14 ms |
2296 KB |
Output is correct |
20 |
Correct |
13 ms |
2380 KB |
Output is correct |
21 |
Correct |
14 ms |
2264 KB |
Output is correct |
22 |
Correct |
14 ms |
2260 KB |
Output is correct |
23 |
Correct |
16 ms |
2264 KB |
Output is correct |
24 |
Correct |
14 ms |
2264 KB |
Output is correct |