-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Contest_Proposal.cpp
More file actions
73 lines (56 loc) · 1.28 KB
/
Copy pathA_Contest_Proposal.cpp
File metadata and controls
73 lines (56 loc) · 1.28 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>
#define ENDL '\n'
#define lli long long
#define pb push_back
#define ff first
#define ss second
#define fore(i,a,b) for(int i=a;i<b;i++)
#define all(s) begin(s), end(s)
#define sz(s) int(s.size())
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
void solve(){
int n ;
cin>>n ;
int res = 0 ;
vector<int>a(n), b(n);
for(int i=0; i<n; ++i){
cin>>a[i];
}
for(int i=0; i<n; ++i){
cin>>b[i];
}
int r = 0 ;
for(int l=0; l < n; ++l ){
if( a[l] <= b[r] ){
r++;
} else if(r < n ){
//cout<<l<<" "<<r<<endl;
while( r < n && a[l] > b[r]){
r++;
res++;
// cout<<"ahora es "<<res<<endl;
}
//cout<<endl;
//cout<<a[l ]<<"es menor que "<<b[r]<<endl;
if( r < n ){
r++;
}
// cout<<l <<" == "<<r<<endl;
if( r >= n){
break;
}
}
}
cout<<res<<endl;
}
int main(){
// freopen("file.in","r",stdin);
// freopen("file.out","w",stdout);
IO;
int t; cin>>t; while(t--)
solve();
return 0;
}