public void solve() throws IOException {
    int n = nextInt();
    Tree[] trees = new Tree[n];
    for (int x = 0; x < n; x++) {
      trees[x] = new Tree(nextInt(), nextInt());
    }
    State start = new State(0, 0, Integer.MIN_VALUE);
    Queue<State> search = new LinkedList<State>();
    search.add(start);
    
    int most = 0;
    HashMap<Integer, Integer> dp = new HashMap<Integer, Integer>();
    while (search.size() > 0) {
      State cur = search.poll();
      Tree tree = trees[cur.nextindex];
      if (tree.pos - tree.height > cur.rightmost) {
        State next = new State(cur.nextindex + 1, cur.trees + 1, tree.pos);
        most = Math.max(most, cur.trees + 1);
        if (dp.containsKey(tree.pos) )
        search.add(next);
      } else {
        
      }
    }
  }