[PAT]甲级1017
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
String[] number=new String[2];
number=read.readLine().split(" ");
int numOfCustomer=Integer.valueOf(number[0]);
int numOfWindows=Integer.valueOf(number[1]);
String[] temp1=new String[2];
String[] time=new String[3];
int temp2;
ArrayList<Customer> customer= new ArrayList<Customer>();
for(int i=0;i<numOfCustomer;i++){
temp1=read.readLine().split(" ");
time=temp1[0].split(":");
temp2=Integer.valueOf(time[0])*3600+Integer.valueOf(time[1])*60+Integer.valueOf(time[2]);
Customer temp3=new Customer(temp2,temp1[1]);
if(temp2>61200) continue;
customer.add(temp3);
}
if(customer.size()==0){
System.out.print("0");
return;
}
int mini,index=0;
for(int i=0;i<customer.size()-1;i++){
mini=customer.get(i).time;
for(int j=i+1;j<customer.size();j++){
if(mini>customer.get(j).time){
mini=customer.get(j).time;
index=j;
}
}
Customer temp3=customer.get(i);
customer.set(i,customer.get(index));
customer.set(index,temp3);
}
int[] window=new int[numOfWindows];
for(int i=0;i<numOfWindows;i++){
window[i]=28800;
}
double reslust=0.0;
for(int i=0;i<customer.size();i++){
int miniFinish=window[0];
int tempIndex=0;
for(int j=1;j<numOfWindows;j++){
if(miniFinish>window[j]){
miniFinish=window[j];
tempIndex=j;
}
}
if(window[tempIndex]<=customer.get(i).time){
window[tempIndex]=customer.get(i).time+customer.get(i).doingTime;
}else{
reslust+=(window[tempIndex]-customer.get(i).time);
window[tempIndex]+=customer.get(i).doingTime;
}
}
reslust=reslust/60/customer.size();
System.out.print(String.format("%.1f",reslust));
}
}
class Customer{
int time;
int doingTime;
public Customer(int time1,String time2){
time=time1;
int a=(int)(Double.parseDouble(time2)*60);
if(a>3600){
doingTime=3600;
}else{
doingTime=a;
}
}
}