-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcont_867_q1.cpp
49 lines (44 loc) · 892 Bytes
/
cont_867_q1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<bits/stdc++.h>
using namespace std;
int fun(vector<int> &a, vector<int> &b,int act_time, int n){
int curr_time=a[0];
int ent= b[0];
act_time= act_time-1;
int index=0;
int mini= *min_element(a.begin(),a.end());
if(mini>act_time){
return -1;
}
else{
for(int i=1;i<n;i++){
if(b[i]>ent && a[i]<=act_time){
index=i;
curr_time=a[i];
ent= b[i];
act_time--;
}
else{
act_time--;
}
}
return(index+1);
}
}
int main(){
int t;
cin>>t;
while(t--){
int n,act_time;
cin>>n>>act_time;
vector<int>a(n);
vector<int>b(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
cin>>b[i];
}
int ans= fun(a,b,act_time,n);
cout<<ans<<"\n";
}
}