# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
658736 |
2022-11-14T18:01:14 Z |
mariaclara |
Stove (JOI18_stove) |
C++17 |
|
55 ms |
2324 KB |
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn = 1e5+10;
#define pb push_back
#define f first
#define s second
int n, k, com, last, resp;
vector<pii> L;
int func(pii a, pii b) {
return a.s - a.f > b.s - b.f;
}
int main () {
cin >> n >> k;
for(int i = 1; i <= n; i++) {
int aux;
cin >> aux;
if(i>1) L.pb({last, aux});
else com = aux;
last = aux+1;
}
resp = last-com;
sort(L.begin(), L.end(), func);
for(int i = 0; i < k-1; i++)
resp -= L[i].s - L[i].f;
cout << resp << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
55 ms |
2256 KB |
Output is correct |
17 |
Correct |
55 ms |
2324 KB |
Output is correct |
18 |
Correct |
48 ms |
2252 KB |
Output is correct |
19 |
Correct |
48 ms |
2224 KB |
Output is correct |
20 |
Correct |
48 ms |
2284 KB |
Output is correct |
21 |
Correct |
49 ms |
2236 KB |
Output is correct |
22 |
Correct |
47 ms |
2252 KB |
Output is correct |
23 |
Correct |
48 ms |
2248 KB |
Output is correct |
24 |
Correct |
53 ms |
2244 KB |
Output is correct |