Java BST O(nlogn)
```   static class Segment{         int start, end, height;     Segment(int s, int e, int h) {         start = s;         end = e;         height = h;     } } p
```
  static class Segment{
        int start, end, height;
        
        Segment(int s, int e, int h) {
            start = s;
            end = e;
            height = h;
        }
    }
    
    public List<Integer> fallingSquares(int[][] positions) {
        
        List<Integer> res = new ArrayList<>();
        TreeSet<Segment> bst = new TreeSet<>((s1, s2) -> Integer.compare(s1.start, s2.start));
        int max = 0;
        
        for(int[] p : positions) {
            Segment current = new Segment(p[0], p[0] + p[1], p[1]);
            Segment left = bst.lower(current);
            if(left != null && left.end > current.start) {
                bst.add(new Segment(current.start, left.end, left.height));
                left.end = current.start;
            }
            
            Segment right = bst.lower(new Segment(current.end, 0, 0));
            if(right != null && right.end > current.end)
                bst.add(new Segment(current.end, right.end, right.height));

            Set<Segment> sub = bst.subSet(current, true, new Segment(current.end, 0, 0), false);
            for(Iterator<Segment> i = sub.iterator(); i.hasNext(); i.remove())
                current.height = Math.max(current.height, i.next().height + p[1]);
            
            bst.add(current);
            
            res.add(max = Math.max(max, current.height));
        }
        
        return res;
    }
```
[]