# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
638916 |
2022-09-07T23:29:23 Z |
rc_catunta |
Stove (JOI18_stove) |
C++14 |
|
34 ms |
3388 KB |
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
int main(){
ios_base::sync_with_stdio(false);
int N,K,x;
vi guests;
vector< ii > te;
cin>>N>>K;
for(int i=0;i<N;i++){
cin>>x;
guests.push_back(x);
}
// Tiempos de Espera
for(int i=0;i<N-1;i++){
te.push_back(ii(guests[i+1]-guests[i],i+1));
}
sort(te.rbegin(),te.rend());
vi posiciones;
for(int i=0;i<K-1;i++){
posiciones.push_back(te[i].second);
}
sort(posiciones.begin(),posiciones.end());
int pos_anterior = 0;
int tiempo = 0;
for(auto p: posiciones){
tiempo += guests[p-1]-guests[pos_anterior]+1;
pos_anterior = p;
}
tiempo += guests[N-1]-guests[pos_anterior]+1;
cout<<tiempo<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 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 |
21 ms |
1816 KB |
Output is correct |
17 |
Correct |
20 ms |
2768 KB |
Output is correct |
18 |
Correct |
20 ms |
2804 KB |
Output is correct |
19 |
Correct |
21 ms |
2744 KB |
Output is correct |
20 |
Correct |
31 ms |
2820 KB |
Output is correct |
21 |
Correct |
34 ms |
3284 KB |
Output is correct |
22 |
Correct |
30 ms |
3388 KB |
Output is correct |
23 |
Correct |
27 ms |
3264 KB |
Output is correct |
24 |
Correct |
29 ms |
3276 KB |
Output is correct |