public static float waitTime(int[] arriveTimes, int[] executeTimes, int q) {
		if (arriveTimes == null || executeTimes == null || arriveTimes.length != executeTimes.length)
			return 0;
		Queue<Process> queue = new LinkedList<Process>();
		int curTime = 0, waitTime = 0;
		int index = 0;
		int length = arriveTimes.length;
		while (!queue.isEmpty() || index < length) {
			if (!queue.isEmpty()) {
				Process cur = queue.poll();
				waitTime += curTime - cur.arrivalTime;
				curTime += Math.min(cur.executeTime, q);
				for (; index < length && arriveTimes[index] <= curTime; index++)
					queue.offer(new Process(arriveTimes[index], executeTimes[index]));
				if (cur.executeTime > q)
					queue.offer(new Process(curTime, cur.executeTime - q));
			} else {
				queue.offer(new Process(arriveTimes[index], executeTimes[index]));
				curTime = arriveTimes[index++];
			}
		}
		
		return (float) waitTime / length;
	}