Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- typedef long long ll;
- #define ldd I64d
- int hi[1003],pos[1003],res[1003];
- void res_gen(int u, int r)
- {
- int ans=1,val=pos[u]+hi[u];
- for(int v=u+1;v<=r;v++)
- {
- if(val>pos[v])ans++;
- val=max(val,hi[v]+pos[v]);
- }
- res[u]=ans;
- }
- int main()
- {
- int n,x;
- scanf("%d",&n);
- for(int i=1;i<=n;i++)scanf("%d",&hi[i]);
- for(int i=1;i<=n;i++)scanf("%d",&pos[i]);
- for(int i=1;i<=n;i++)res_gen(i,n);
- int q;
- scanf("%d",&q);
- while(q--)
- {
- scanf("%d",&x);
- printf("%d\n",res[x]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement