package leetcode;

/**
 * https://leetcode.com/problems/champagne-tower/
 */
public class Problem799 {
    public double champagneTower(int poured, int query_row, int query_glass) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem799 prob = new Problem799();
        System.out.println(prob.champagneTower(1, 1, 1)); // 0.0
        System.out.println(prob.champagneTower(2, 1, 1)); // 0.5
    }
}

@@ -187,32 +187,858 @@
     
-// TODO%0A        return 0
+double%5B%5D%5B%5D glasses = new double%5B100%5D%5B100%5D;%0A        int row = 0;%0A        glasses%5Brow%5D = new double%5B%5D%7Bpoured%7D;%0A        while (row %3C glasses.length) %7B%0A            int colIdx = 0;%0A            boolean overflow = false;%0A            for (int col = 0; col %3C glasses%5Brow%5D.length; col++) %7B%0A                double val = glasses%5Brow%5D%5Bcol%5D;%0A                if (val == 0) %7B%0A                    break;%0A                %7D%0A                if (val %3E 1) %7B%0A                    glasses%5Brow%5D%5Bcol%5D = 1;%0A                    double half = (val - 1) / 2;%0A                    glasses%5Brow + 1%5D%5BcolIdx++%5D += half;%0A                    glasses%5Brow + 1%5D%5BcolIdx++%5D += half;%0A                    overflow = true;%0A                %7D%0A            %7D%0A            if (!overflow) %7B%0A                break;%0A            %7D%0A            row++;%0A        %7D%0A        return glasses%5Bquery_row%5D%5Bquery_glass%5D
 ;%0A  
@@ -1131,16 +1131,18 @@
 m799();%0A
+//
         
@@ -1198,16 +1198,18 @@
  // 0.0%0A
+//
         
@@ -1265,16 +1265,551 @@
  // 0.5%0A
+//        System.out.println(prob.champagneTower(3, 0, 0)); // 1.0%0A//        System.out.println(prob.champagneTower(3, 1, 1)); // 1.0%0A//        System.out.println(prob.champagneTower(3, 2, 0)); // 0.0%0A//        System.out.println(prob.champagneTower(3, 2, 1)); // 0.0%0A//        System.out.println(prob.champagneTower(4, 2, 0)); // 0.25%0A//        System.out.println(prob.champagneTower(4, 1, 0)); // 1.0%0A//        System.out.println(prob.champagneTower(4, 1, 1)); // 1.0%0A        System.out.println(prob.champagneTower(4, 2, 1)); // 0.5%0A
     %7D%0A%7D%0A

Update problem 799