#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
struct people{
int come,time;
people(int ss,int tt):come(ss),time(tt){}
};
bool cmp1(people a,people b){
return a.come<b.come;
}
int main() {
int n,k;
cin>>n>>k;
vector<people> p;
for(int i=0;i<n;i++){
int hh,mm,ss,tt;
scanf("%d:%d:%d %d",&hh,&mm,&ss,&tt);
int sum=(hh*60+mm)*60+ss;
if(sum>61200) continue;
p.push_back(people(sum,tt*60));
}
sort(p.begin(),p.end(),cmp1);
int cnt=p.size(),waitTime=0;
priority_queue<int ,vector<int>,greater<int>>q;
for(int i=0;i<k;i++) q.push(28800);
for(int i=0;i<cnt;i++){
if(q.top()<=p[i].come){
q.push(p[i].come+p[i].time);
q.pop();
}else{
waitTime+=q.top()-p[i].come;
q.push(q.top()+p[i].time);
q.pop();
}
}
cnt?printf("%.1lf",(double)waitTime/60.0/(double)cnt):printf("0.0");
return 0;
}
|