#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 10000
#define K 100
int main(int argc, char **argv) {
int n, k;
int lst[K];
int sq[N];
int wt = 0;
int count = 0;
cin >> n >> k;
for(int i = 0; i < k; i ++) {
lst[i] = 8*60*60;
}
for(int i = 0; i < n; i ++) {
int h, m, s, w;
scanf("%d:%d:%d %d", &h, &m, &s, &w);
int ct = h*60*60 + m*60 + s;
sq[i] = (ct << 8) | w;
}
sort(sq, sq+n);
for(int i = 0; i < n; i ++) {
int ct = sq[i] >> 8;
int w = sq[i] & 0xFF;
if(ct > 17*60*60)
continue;
int sw = 0;
for(int i = 0; i < k; i ++) {
if(lst[i] < lst[sw])
sw = i;
}
count ++;
w *= 60;
if(ct > lst[sw]) {
lst[sw] = ct + w;
}
else {
wt += (lst[sw] - ct);
lst[sw] += w;
}
}
double awt = 0;
if(count)
awt = wt / 60.0 / count;
printf("%.1lf\n", awt);
return 0;
}
1017. Queueing at Bank (25)
最新推荐文章于 2018-02-26 17:13:00 发布