Untitled
unknown
c_cpp
a year ago
1.2 kB
11
Indexable
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int , int>
#define pb emplace_back
#define endl '\n'
#define sz(x) (int)((x).size())
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define F first
#define S second
const int mod = 998244353;
const int MAXX = 2e5 + 5;
const int N = 1e6;
const int INF = INT_MAX;
int t , n;
int a[MAXX];
int b[MAXX];
signed main()
{
_FastIO;
cin >> t;
while(t--){
cin >> n;
for(int i = 0; i < n; i++){
cin >> b[i];
}
for(int i = 0; i < n; i++){
cin >> a[i];
}
sort(a , a + n);
sort(b , b + n);
int l = 0 , r = 0;
int ind = n;
int ans = 0;
while((l < n) && (r < n)){
if(a[l] >= b[r]){
l++;
r++;
ans += ind;
ind--;
}else{
l++;
}
}
cout << ans << endl;
}
return 0;
}Editor is loading...
Leave a Comment