注意点:1,只要在17:00点前到达,即使因为排队等至17点后,也会被服务;
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn=10010;
struct client{
int atime,ptime;
}cl[maxn];
int N,K,validn=0;
int window[150];
bool cmp(client a,client b){
return a.atime<b.atime;
}
int main(){
scanf("%d%d",&N,&K);
for(int i=0;i<N;i++){
int th,tm,ts,tp;
scanf("%d:%d:%d%d",&th,&tm,&ts,&tp);
int temp=th*3600+tm*60+ts;
if(temp>17*3600) continue; // 只要在17:00点前到达,即使因为排队等至17点后,也会被服务
cl[validn].atime=temp;
if(tp<60) cl[validn].ptime=tp*60;
else cl[validn].ptime=60*60;
validn++;
}
fill(window,window+K,-1);
sort(cl,cl+validn,cmp);
int sumtime=0,countc=0,index=0;
bool finish=false;
for(int nowt=8*3600;index<validn;nowt++){ //
for(int i=0;i<K&&index<validn;i++){
if(window[i]==-1){
if(nowt>=cl[index].atime){
sumtime+=(nowt-cl[index].atime);
countc++;
window[i]=index++;
}
}else{
cl[window[i]].ptime--;
if(cl[window[i]].ptime==0){ //处理完当前客户的服务
if(nowt>=cl[index].atime){
sumtime+=(nowt-cl[index].atime);
countc++;
window[i]=index++;
}else window[i]=-1; //
}
}
}
}
if(countc==0) printf("0.0");
else printf("%.1f",sumtime*1.0/(countc*1.0)/60.0);
return 0;
}