package leetcode;

/**
 * https://leetcode.com/problems/average-waiting-time/
 */
public class Problem1701 {
    public double averageWaitingTime(int[][] customers) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1701 prob = new Problem1701();
        System.out.println(prob.averageWaitingTime(new int[][]{{1,2},{2,5},{4,3}})); // 5.00000
        System.out.println(prob.averageWaitingTime(new int[][]{{5,2},{5,4},{10,3},{20,1}})); // 3.25000
        System.out.println(prob.averageWaitingTime(new int[][]{{1,10},{2,1},{3,4}})); // 11.00000
    }
}


@@ -172,429 +172,461 @@
     
-// TODO%0A        return 0
+double answer = 0;%0A        int currentTime = customers%5B0%5D%5B0%5D
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1701 prob = new Problem1701();%0A        System.out.println(prob.averageWaitingTime(new int%5B%5D%5B%5D%7B%7B1,2%7D,%7B2,5%7D,%7B4,3%7D%7D)); // 5.00000%0A        System.out.println(prob.averageWaitingTime(new int%5B%5D%5B%5D%7B%7B5,2%7D,%7B5,4%7D,%7B10,3%7D,%7B20,1%7D%7D)); // 3.25000%0A        System.out.println(prob.averageWaitingTime(new int%5B%5D%5B%5D%7B%7B1,10%7D,%7B2,1%7D,%7B3,4%7D%7D)); // 11.00000
+for (int i = 0; i %3C customers.length; i++) %7B%0A            int arrival = customers%5Bi%5D%5B0%5D;%0A            int time = customers%5Bi%5D%5B1%5D;%0A            if (arrival %3E currentTime) %7B%0A                currentTime = arrival + time;%0A            %7D else %7B%0A                currentTime += time;%0A            %7D%0A            answer += currentTime - arrival;%0A        %7D%0A        return answer / customers.length;
 %0A   

Solve problem 1701