Codeforces Round 867 (Div. 3) A - TubeTube Feed Solution
Problem Link : https://codeforces.com/contest/1822/problem/A
Solution in C++:
- /// Author : AH_Tonmoy
 - #include <bits/stdc++.h>
 - using namespace std;
 - int32_t main() {
 - ios_base::sync_with_stdio(0);
 - cin.tie(0);
 - int t;
 - cin >> t;
 - while (t--) {
 - int n , ts ;
 - cin >> n >> ts ;
 - int a[n+1],b[n+1] ;
 - for ( int i = 0 ; i < n ; i++) cin >> a[i] ;
 - for ( int i = 0 ; i < n ; i++) cin >> b[i] ;
 - int ans = - 2 ;
 - for ( int i = 0 ; i < n ; i++ ) {
 - if ( i + a[i] <= ts) {
 - if ( ans == -2 || b[ans] < b[i] ) {
 - ans = i ;
 - }
 - }
 - }
 - cout << ans + 1 << endl;
 - }
 - }
 


No comments