# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1017503 |
2024-07-09T08:30:25 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
0 ms |
348 KB |
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int main() {
int N,K;
cin>>N>>K;
vector<int> arrivals(N);
for(int i=0; i<N; ++i) {
cin>>arrivals[i];
}
sort(arrivals.begin(),arrivals.end());
priority_queue<int,vector<int>,greater<int>> pq;
int current_matches=0;
long long total_time = 0;
for(int i=0; i<N; ++i) {
int guest_arrival=arrivals[i];
if(current_matches<K) {
current_matches++;
total_time+=1;
pq.push(guest_arrival+1);
} else {
int earliest_leave_time=pq.top();
if(earliest_leave_time<guest_arrival) {
pq.pop();
total_time+=earliest_leave_time-guest_arrival;
pq.push(guest_arrival+1);
}
}
}
cout<<total_time<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |