public static float shortJobFirst(int[] tasks, int[] dur) {
		if (tasks == null || dur == null || tasks.length != dur.length) return 0;
		
		PriorityQueue<Process> queue = new PriorityQueue<Process>(new Comparator<Process>() {
			@Override
			public int compare(Process p1, Process p2) {
				if (p1.executeTime == p2.executeTime) {
					return p1.arrivalTime - p2.arrivalTime;
				}
				return p1.executeTime - p2.executeTime;
			}
		});
		
		int length = tasks.length;
		int waitTime = 0;
		int currTime = 0;
		int i = 0;
		while (!queue.isEmpty() || i < length) {
			if (!queue.isEmpty()) {
				Process cur = queue.poll();
				waitTime += currTime - cur.arrivalTime;
				currTime += cur.executeTime;
				while (i < length && currTime >= tasks[i]) {
					queue.offer(new Process(tasks[i], dur[i]));
					i++;
				}
			} else {
				queue.offer(new Process(tasks[i], dur[i]));
				currTime = tasks[i];
				i++;
			}
		}
		
		return (float) waitTime /length;
	}