假设银行有K个窗口提供服务,窗口前设一条黄线,所有顾客按到达时间在黄线后排成一条长龙。当有窗口空闲时,下一位顾客即去该窗口处理事务。当有多个窗口可选择时,假设顾客总是选择编号最小的窗口。

本题要求输出前来等待服务的N位顾客的平均等待时间、最长等待时间、最后完成时间,并且统计每个窗口服务了多少名顾客。

输入格式:
输入第1行给出正整数N(≤1000),为顾客总人数;随后N行,每行给出一位顾客的到达时间T和事务处理时间P,并且假设输入数据已经按到达时间先后排好了顺序;最后一行给出正整数K(≤10),为开设的营业窗口数。这里假设每位顾客事务被处理的最长时间为60分钟。

输出格式:
在第一行中输出平均等待时间(输出到小数点后1位)、最长等待时间、最后完成时间,之间用1个空格分隔,行末不能有多余空格。

在第二行中按编号递增顺序输出每个窗口服务了多少名顾客,数字之间用1个空格分隔,行末不能有多余空格。

输入样例:
9
0 20
1 15
1 61
2 10
10 5
10 3
30 18
31 25
31 2
3
输出样例:
6.2 17 61
5 3 1

import java.text.DecimalFormat;
import java.util.*;

//队列接口
interface IQueue{
	public boolean isEmpty();//判断队列是否为空
	public People poll();//将队首元素删除并返回其值
	public void offer (People x);//将数据x插入到队列
	public People peek();//返回队首元素
}
//定义顾客类
class People{
	public int waittime;
	public int arrivalTime;
	public int spendTime;
	public People(){
		
	}
	public People(int arrivalTime, int spendTime , int waittime) {
		this.arrivalTime = arrivalTime;
		this.spendTime = spendTime;
		this.waittime = waittime;
	}
	
}
//实现接口
class SqQueue implements IQueue{
	private People[] queueElem;//队列的存储空间
	private int front;//指向队首元素
	private int rear;//指向队尾元素的下一存储单元
	private int maxSize;//队列的最大存储单元个数
	public SqQueue(int maxSize) {
		front = rear = 0;
		queueElem = new People[maxSize];
		this.maxSize = maxSize;
	}

	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return front == rear;
	}
	
	@Override
	public People poll() {
		// TODO Auto-generated method stub
		if (front == rear)
			return null;
		People p = queueElem[front];
		front ++;
		return p;
	}

	@Override
	public void offer(People x){
		// TODO Auto-generated method stub
		queueElem[rear] = x;
		rear ++;
	}

	@Override
	public People peek() {
		// TODO Auto-generated method stub
		if (rear == 0)
			return null;
		return queueElem[front];
	}
	
	//计算等待时间
	public void addwait(int time){
		for(int i = front; i < rear; i ++){
			queueElem[i].waittime += time;
		}
	}
	
	public int getFront() {
		return front;
	}

	public int getRear() {
		return rear;
	}
	
	
	
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();//顾客数
		People [] people = new People[N];
		SqQueue queue = new SqQueue(N);//定义队列,存放等待的顾客
		//存放所有的顾客
		for(int i = 0; i < N; i++){
			people[i]= new People(sc.nextInt() , sc.nextInt() ,0);
			if(people[i].spendTime > 60){
				people[i].spendTime = 60;
			}
		}
		int K = sc.nextInt();//窗口数
		int [] windows = new int[K];
		int [] winpeo = new int[K];//存储每个窗口接待的人数
		for(int i = 0; i < K; i++){
			windows[i] = 0;
			winpeo[i] = 0;
		}
		int waitTime = 0;//定义总等待时间
		int maxwaitTime = 0;//最大等待时间
		int k,c;
		
		int time = -1;//定义时间线
		int l = 0;//当前顾客序号
		while(!(queue.isEmpty() && l == N)){
			//时间+1,队列中每个顾客等待时间+1,每个窗口-1
			time ++;
			queue.addwait(1);
			for(int i = 0; i < K; i++){
				if(windows[i] > 1){
					windows[i] -= 1;
				}
				else{
					windows[i] = 0;
				}
			}
			//顾客到达时间等于当前时间,入队
			for(int i = l; i < N; i++){
				if(people[l].arrivalTime == time){
					queue.offer(people[l]);
					l ++;
				}
				else{
					break;
				}
			}
			People people1 = new People();
			//第一个顾客去一号窗口
			if(!queue.isEmpty()){
					//找空闲窗口,如果有出队
					for(k = 0; k < K; k++){
						if(queue.isEmpty()){
							break;
						}
						if(windows[k] == 0){
							people1 = queue.poll();
							windows[k] += people1.spendTime;
							winpeo[k] ++;
							waitTime +=people1.waittime;
							if(people1.waittime > maxwaitTime){
								maxwaitTime = people1.waittime;
							}
						}
					}
				}
			}
		
		int max = 0;//找最大的窗口剩余时间,因为while循环结束的时候,还有顾客在窗口
		for(int i = 0; i < K; i++){
			if(windows[i] > max){
				max = windows[i];
			}
		}
		time += max;
		//输出
		float atime = (float) waitTime/ N;
		DecimalFormat df = new DecimalFormat("#.0");
		if(atime == 0.0){
			System.out.println( atime + " " + maxwaitTime + " " + time);
		}
		else{
			System.out.println( df.format(atime) + " " + maxwaitTime + " " + time);
		}
		
		for(int i = 0; i < K; i++){
			if(i == 0){
				System.out.print(winpeo[i]);
			}
			else{
				System.out.print(" " + winpeo[i]);
			}
		}
	}
}