private static int[] getGridLines(int[] pos, int[] heights) {
    int[] result = new int [pos.length + 1];
    result [0] = pos[0];
    for(int i = 0; i < pos.length - 1; i++) {
      result [i+1] = (pos[i] + heights[i] + pos[i + 1]) / 2;
    }
    result [pos.length] = pos[pos.length - 1] + heights[pos.length - 1];
    return result;
  }
private static int[] getGridLines(int[] pos, int[] heights)