#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
#define maxn 1e+9
#define K 111
struct Customer{
int cometime;
int servetime;
}newCustomer;
int End[K];
vector<Customer>custom;
int change(int h,int m,int s)
{
return h*3600+m*60+s;
}
bool cmp(Customer a,Customer b)
{
return a.cometime<b.cometime;
}
int main()
{
int c,w;
int time=0;
scanf("%d%d",&c,&w);
int stime=change(8,0,0);
int etime=change(17,0,0);
for(int i=0;i<w;i++)
{
End[i]=stime;
}
for(int i=0;i<c;i++)
{
int h,m,s,servetime;
scanf("%d:%d:%d %d",&h,&m,&s,&servetime);
int cometime=change(h,m,s);
if(cometime>etime)
continue;
newCustomer.cometime=cometime;
newCustomer.servetime=servetime<=60?servetime*60:3600;
custom.push_back(newCustomer);
}
sort(custom.begin(),custom.end(),cmp);
for(int i=0;i<custom.size();i++)
{
int idx=-1,mintime=maxn;
for(int j=0;j<w;j++)
{
if(End[j]<mintime)
{
mintime=End[j];
idx=j;
}
}
if(End[idx]<=custom[i].cometime)
{
End[idx]=custom[i].cometime+custom[i].servetime;
}
else
{
time+=(End[idx]-custom[i].cometime);
End[idx]+=custom[i].servetime;
}
}
if(custom.size()==0)
printf("0.0");
else
printf("%.1f",time/60.0/custom.size());
return 0;
}
PAT——A1017 Queueing at Bank
猜你喜欢
转载自blog.csdn.net/qq_42232118/article/details/82417890
今日推荐
周排行