点击打开pat链接#include<iostream>
#include<math.h>
#include<algorithm>
#include<map>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define INF 100000000
#define maxn 100010
struct customer{
int time,sertime;
}newcustomer;
bool cmp(customer a,customer b)
{
return a.time<b.time;
}
int main(){
int n,k;
double sum=0;
cin>>n>>k;
int endtime[maxn]={0};
int h,m,s,sert;
int temp;
vector<customer> guest;
for(int i=0;i<n;i++)
{
scanf("%d:%d:%d %d",&h,&m,&s,&sert);
temp=h*3600+m*60+s;
if(sert>60) sert=60;
newcustomer.sertime=sert*60;
newcustomer.time=temp;
if(temp<17*3600) guest.push_back(newcustomer);
}
sort(guest.begin(),guest.end(),cmp);
int stime=8*3600;
for(int i=0;i<k;i++)
endtime[i]=stime;
int store,id,j;
for(int i=0;i<guest.size();i++)
{store=INF,id=-1;
for(j=0;j<k;j++)
{ if(endtime[j]<store) {
store=endtime[j];
id=j;
}}
//cout<<id<<store<<guest[0].time;
if(store>guest[i].time) {sum+=(endtime[id]-guest[i].time);
endtime[id]+=guest[i].sertime;
}
else endtime[id]=guest[i].time+guest[i].sertime;
#include<math.h>
#include<algorithm>
#include<map>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define INF 100000000
#define maxn 100010
struct customer{
int time,sertime;
}newcustomer;
bool cmp(customer a,customer b)
{
return a.time<b.time;
}
int main(){
int n,k;
double sum=0;
cin>>n>>k;
int endtime[maxn]={0};
int h,m,s,sert;
int temp;
vector<customer> guest;
for(int i=0;i<n;i++)
{
scanf("%d:%d:%d %d",&h,&m,&s,&sert);
temp=h*3600+m*60+s;
if(sert>60) sert=60;
newcustomer.sertime=sert*60;
newcustomer.time=temp;
if(temp<17*3600) guest.push_back(newcustomer);
}
sort(guest.begin(),guest.end(),cmp);
int stime=8*3600;
for(int i=0;i<k;i++)
endtime[i]=stime;
int store,id,j;
for(int i=0;i<guest.size();i++)
{store=INF,id=-1;
for(j=0;j<k;j++)
{ if(endtime[j]<store) {
store=endtime[j];
id=j;
}}
//cout<<id<<store<<guest[0].time;
if(store>guest[i].time) {sum+=(endtime[id]-guest[i].time);
endtime[id]+=guest[i].sertime;
}
else endtime[id]=guest[i].time+guest[i].sertime;
}
double ave=sum/60/guest.size();
printf("%.1lf",ave);
}
double ave=sum/60/guest.size();
printf("%.1lf",ave);
}