fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int q;
  7. cin>>q;
  8. while(q--)
  9. {
  10. int n,t;
  11. cin>>n>>t;
  12. int d[n],c[n],j=0;
  13. for(int i=0;i<n;i++) cin>>d[i];
  14. for(int i=0;i<n;i++) cin>>c[i];
  15. int count=0,temp=0;
  16. for( j=0;j<n;j++)
  17. {
  18. if((j+d[j]<t))
  19. {
  20. count=max(count,c[j]);
  21. if(c[j]>=count)
  22. {
  23. continue;
  24. }
  25. }
  26. }
  27. cout<<j+1<<"\n";
  28.  
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5432KB
stdin
5
5 9
1 5 7 6 6
3 4 7 1 9
4 4
4 3 3 2
1 2 3 4
5 7
5 5 5 5 5
2 1 3 9 7
4 33
54 71 69 96
42 24 99 1
2 179
55 66
77 88
stdout
6
5
6
5
3