AcWing 1236. 递增三元组
原题链接
中等
作者:
许.
,
2025-04-04 19:39:37
· 天津
,
所有人可见
,
阅读 1
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
int a[N], b[N], c[N];
int n;
long long res;
int main() {
ios:: sync_with_stdio (false);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (int i = 0; i < n; i++) cin >> b[i];
for (int i = 0; i < n; i++) cin >> c[i];
sort(c, c + n);
res = 0;
for (int i = 0; i < n; i++) {
int x = b[i];
int l = lower_bound(a, a + n, x) - a;
int r_pos = upper_bound(c, c + n, x) - c;
int r = n - r_pos;
res += (long long)l * r;
}
cout << res << endl;
return 0;
}