fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int a[11111], b[11111];
  5.  
  6. int main() {
  7. int t;
  8. cin >> t;
  9. while (t --> 0) {
  10. int n;
  11. cin >> n;
  12. for(int i = 0; i < n; ++i)
  13. cin >> a[i];
  14. for(int i = 0; i < n; ++i)
  15. cin >> b[i];
  16. int ans = 0, last = 0;
  17. for(int i = 0; i < n; ++i) {
  18. if (a[i] >= last + b[i])
  19. ans++;
  20.  
  21. last += b[i];
  22. if (last > a[i])
  23. last = a[i];
  24. }
  25. cout << ans << "\n";
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 3500KB
stdin
2
3
1 10 15
1 10 3
3
10 20 30
15 5 20
stdout
2
1