File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+ using ll = int64_t ;
5
+ using ff = long double ;
6
+
7
+ int main () {
8
+ ios_base::sync_with_stdio (false );
9
+ cin.tie (0 ); cout.tie (0 );
10
+
11
+ int N;
12
+ cin >> N;
13
+
14
+ vector<int > A (N), B (N), C (N);
15
+ for (auto &a : A) cin >> a;
16
+ for (auto &b : B) cin >> b;
17
+ for (auto &c : C) cin >> c;
18
+ sort (A.begin (), A.end ());
19
+ sort (B.begin (), B.end ());
20
+ sort (C.begin (), C.end ());
21
+
22
+ vector<ll> DP (N, 0 );
23
+ for (int i = 0 ; i < N; ++i) {
24
+ auto it = lower_bound (A.begin (), A.end (), B[i]);
25
+ int s = distance (A.begin (), it);
26
+ DP[i] = s;
27
+ }
28
+ for (int i = 1 ; i < N; ++i) {
29
+ DP[i] += DP[i-1 ];
30
+ }
31
+ ll ans = 0 ;
32
+ for (auto c : C) {
33
+ auto it = lower_bound (B.begin (), B.end (), c);
34
+ int s = distance (B.begin (), it);
35
+ if (s > 0 ) {
36
+ ans += DP[s-1 ];
37
+ }
38
+ }
39
+ cout << ans << endl;
40
+
41
+ return 0 ;
42
+ }
You can’t perform that action at this time.
0 commit comments