Suppose a bank has K windows open for service. There was a yellow line in front of the windows which devides the waiting area into the parts. All the customers has to wait for line behind the Yellow Line, until it's his/her turn to being served and there is a window Available. It is assumed this no window can be occupied by a single customer for more than 1 hour.
Now given the arriving time T and the processing time P of each customer, you is supposed to tell the average waiting Tim E of all the customers.
Input Specification:
Each input file contains the one test case. The first line contains 2 numbers:n (<=10000)-the total number of customers, and K (<=100)-The N Umber of Windows. Then N lines follow, each contains 2 times:hh:mm:ss-the arriving time, and p-the processing time in minutes of a Cust Omer. Here HH was in the range [XX,], MM and SS are both in [00, 59]. It is assumed, that no, customers arrives at the same time.
Notice the bank opens from 17:00. Anyone arrives early'll has to wait for line till, and anyone comes too late (at or after 17:00:01) won't be SE RVed nor counted into the average.
Output Specification:
For each test case, print on one line the average waiting time of the "all" the customers, in minutes and accurate up to 1 DECIM Al Place.
Sample Input:
7 307:55:00 1617:00:01 207:59:59 1508:01:00 6008:00:00 3008:00:02 208:03:00 10
Sample Output:
8.2
1#include <stdio.h>2#include <vector>3#include <algorithm>4 using namespacestd;5 structcus6 {7 intArrive_time,cost;8 };9 structwinTen { OneWin (): Win_time (8* -* -){} A intWin_time; - }; - theWin wins[ $]; - - BOOLcmparrive (cus a,cus b) - { + returnA.arrive_time <B.arrive_time; - } + intMain () A { at intN,w_num,hh,mm,ss; - cus Ctem; -Vector<cus>VV; -scanf"%d%d",&n,&w_num); - for(inti =0; I < n;++i) - { inscanf"%d:%d:%d%d",&hh,&mm,&ss,&ctem.cost); - if(Ctem.cost > -) toCtem.cost = -; +Ctem.cost *= -; -Ctem.arrive_time = hh* -* -+ mm* -+SS; the if(Ctem.arrive_time <= -* -* -) * Vv.push_back (ctem); $ }Panax Notoginseng sort (Vv.begin (), Vv.end (), cmparrive); - intCNT =0; the Doublesum =0.0; +n =vv.size (); A while(CNT <N) the { + intMIN =99999999; - intMinindex =-1; $ for(inti =0; I < w_num;++i) $ { - if(MIN >wins[i].win_time) - { theMIN =Wins[i].win_time; -Minindex =i;Wuyi } the } - if(MIN >vv[cnt].arrive_time) Wu { -Sum + = (MIN-vv[cnt].arrive_time); AboutWins[minindex].win_time + =Vv[cnt].cost; $++CNT; - } - Else - { A for(inti =0; I < w_num;++i) + { the if(Vv[cnt].arrive_time >=wins[i].win_time) - { $Minindex =i; the Break; the } the } theWins[minindex].win_time = Vv[cnt].arrive_time +Vv[cnt].cost; -++CNT; in } the } the if(n = =0) Aboutprintf"0.0\n"); the Else theprintf"%.1lf\n", sum/60.0/n); the return 0; +}
1017. Queueing at Bank (25)