注意单位
#include <bits/stdc++.h>
using namespace std;
typedef struct
{
int stamp;
int process_time;
} person;
typedef struct
{
int hh;
int mm;
int ss;
} times;
int times2stamp(times t)
{
return t.ss + t.mm * 60 + t.hh * 60 * 60;
}
times stamp2times(int stamp)
{
times t;
t.ss = stamp % 60;
t.mm = stamp / 60 % 60;
t.hh = stamp / 60 / 60;
return t;
}
bool time_order(person a, person b)
{
return a.stamp < b.stamp;
}
int main()
{
int n, k;
cin >> n >> k;
person people[n];
times t;
char c;
for (int i = 0; i < n; i++)
{
cin >> t.hh >> c >> t.mm >> c >> t.ss;
people[i].stamp = times2stamp(t);
cin >> people[i].process_time;
people[i].process_time *= 60;
}
sort(people, people + n, time_order);
for (int i = n - 1; i >= 0; i--)
{
if (people[i].stamp > 17 * 60 * 60)
n--;
}
if (n == 0)
{
cout << "0.0" << endl;
return 0;
}
int total_wait_time = 0;
int finish_time[k];
memset(finish_time, 0, sizeof(finish_time));
int served = 0;
int time = max(8 * 3600, people[0].stamp);
while (served < n)
{
int free;
for (int i = 0; i < k; i++)
{
if (finish_time[i] == 0 || time == finish_time[i])
{
free = i;
break;
}
}
time = max(time, people[served].stamp);
total_wait_time += time - people[served].stamp;
finish_time[free] = time + people[served].process_time;
served++;
int minn = 1e8;
for (int i = 0; i < k; i++)
{
minn = min(minn, finish_time[i]);
}
if (minn != 0)
time = minn;
}
printf("%.1f\n", total_wait_time * 1.0 / 60 / n);
}