Codeforces Round 867 (Div. 3) A - TubeTube Feed Solution

                      


Problem Link : https://codeforces.com/contest/1822/problem/A

Solution in C++:

  1. /// Author : AH_Tonmoy
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int32_t main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n , ts ;
  11. cin >> n >> ts ;
  12. int a[n+1],b[n+1] ;
  13. for ( int i = 0 ; i < n ; i++) cin >> a[i] ;
  14. for ( int i = 0 ; i < n ; i++) cin >> b[i] ;
  15. int ans = - 2 ;
  16. for ( int i = 0 ; i < n ; i++ ) {
  17. if ( i + a[i] <= ts) {
  18. if ( ans == -2 || b[ans] < b[i] ) {
  19. ans = i ;
  20. }
  21. }
  22. }
  23. cout << ans + 1 << endl;
  24. }
  25. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.