思路:1≤i,j,k≤N Ai<Bj<Ck可以枚举Bj,然后在Ai中找到最大的满足<Bj的,Ck中找最小满足的(找的时候用二分找)
#include <iostream>
#include <algorithm>
using namespace std;
long long ll = 1;
int n;
const int N = 1e5 + 10;
int a[N],b[N],c[N];
long long res;
int main(){
cin>>n;
for(int i = 0;i<n;i++)
scanf("%d",&a[i]);
for(int i = 0;i<n;i++)
scanf("%d",&b[i]);
for(int i = 0;i<n;i++)
scanf("%d",&c[i]);
sort(a,a+n);
sort(b,b+n);
sort(c,c+n);
for(int i = 0;i<n;i++){
int l = -1,r = n-1;
while(l < r){
int mid = l + r + 1 >> 1;
if(a[mid] < b[i])
l = mid ;
else
r = mid - 1;
}
int t = l + 1;
l = 0,r = n;
while(l < r){
int mid = l + r >> 1;
if(c[mid] > b[i])
r = mid;
else
l = mid +1;
}
res += ll*t * (n-l );
}
cout<<res<<endl;
return 0;
}