Advertisement
jakaria_hossain

Toph - dominoes forever

Oct 2nd, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. typedef long long ll;
  5. #define ldd I64d
  6. int hi[1003],pos[1003],res[1003];
  7. void res_gen(int u, int r)
  8. {
  9. int ans=1,val=pos[u]+hi[u];
  10. for(int v=u+1;v<=r;v++)
  11. {
  12. if(val>pos[v])ans++;
  13. val=max(val,hi[v]+pos[v]);
  14. }
  15. res[u]=ans;
  16. }
  17. int main()
  18. {
  19. int n,x;
  20. scanf("%d",&n);
  21. for(int i=1;i<=n;i++)scanf("%d",&hi[i]);
  22. for(int i=1;i<=n;i++)scanf("%d",&pos[i]);
  23. for(int i=1;i<=n;i++)res_gen(i,n);
  24. int q;
  25. scanf("%d",&q);
  26. while(q--)
  27. {
  28. scanf("%d",&x);
  29. printf("%d\n",res[x]);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement