D
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 3e5 + 10, mod = 1e7 + 10;
int a[N], b[N], c[N], d[N];
int n;
void print(int x)
{
if(x == n) return ;
print(c[x]);
printf("%d ", x);
}
int main()
{
cin >> n;
LL sum = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i ++) {
cin >> b[i];
}
d[n] = 0;
queue<int> q;
int dis = n;
q.push(n);
while (!q.empty()) {
int x = q.front();//当前位置
q.pop();
if (x <= 0) {
printf("%d\n", d[x]);
print(x);
return 0;
}
int fall = x + b[x];//滑下落之后
int jump = fall - a[fall];//滑下去之后继续向上跳的位置
for (int i = min(dis - 1, fall - 1); i >= jump; i --) {//
d[i] = d[x] + 1;//这些位置跳的次数加一
c[i] = x;//记录跳跃后的位置
q.push(i);
}
dis = min(dis, jump);//跳的过程中最小之值,只有之后搜的比这个小才有搜的必要性
}
cout << -1 << endl;
return 0;
}
/*
2 2 2 3 3
*/