Advertisement
Anik_Akash

Codeforces Round #743 (Div. 2) B.Swaps

Sep 25th, 2021
1,355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4. int main() {
  5.  
  6.     int tt; cin>>tt;
  7.     while(tt--){
  8.         int n; cin>>n;
  9.         vector<int>a1(n), a2(n);
  10.         for(int i=0; i<n; i++)cin>>a1[i];
  11.         for(int i=0; i<n; i++)cin>>a2[i];
  12.  
  13.         if(a1[0]<a2[0])cout<<0<<endl;
  14.         else{
  15.             int x=0, y=0;
  16.             for(int i=0; i<n; i++){
  17.                 if(a1[i]<a2[0]){
  18.                     x = i; break;
  19.                 }
  20.             }
  21.             for(int i=0; i<n; i++){
  22.                 if(a2[i]>a1[0]){
  23.                     y = i;
  24.                     break;
  25.                 }
  26.             }
  27.             // cout<<x<<" "<<y<<endl;
  28.             cout<<min(x,y)<<endl;
  29.         }
  30.     }
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement