Submission #5324338


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());

  long ans = 0;
  for (int i = 0; i < N; i++) {
    auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
    auto Iter2 = upper_bound(C.begin(), C.end(), B[i]);
    long k1 = Iter1 - A.begin();
    long k2 = C.end() - Iter2;
    ans += k1 * k2;
  }
  cout << ans << "\n";
  return 0;
}

Submission Info

Submission Time
Task C - Snuke Festival
User yamakasa
Language C++14 (GCC 5.4.1)
Score 300
Code Size 716 Byte
Status
Exec Time 60 ms
Memory 1408 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 300 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 59 ms 1408 KB
02.txt 58 ms 1408 KB
03.txt 54 ms 1408 KB
04.txt 54 ms 1408 KB
05.txt 41 ms 1408 KB
06.txt 41 ms 1408 KB
07.txt 36 ms 1408 KB
08.txt 36 ms 1408 KB
09.txt 31 ms 1408 KB
10.txt 31 ms 1408 KB
11.txt 29 ms 1408 KB
12.txt 29 ms 1408 KB
13.txt 54 ms 1408 KB
14.txt 56 ms 1408 KB
15.txt 52 ms 1408 KB
16.txt 53 ms 1408 KB
17.txt 56 ms 1408 KB
18.txt 54 ms 1408 KB
19.txt 60 ms 1408 KB
20.txt 27 ms 1408 KB
21.txt 27 ms 1408 KB
22.txt 41 ms 1408 KB
23.txt 53 ms 1408 KB
24.txt 54 ms 1408 KB
25.txt 54 ms 1408 KB
26.txt 1 ms 256 KB
27.txt 1 ms 256 KB
28.txt 1 ms 256 KB
29.txt 1 ms 256 KB
s1.txt 1 ms 256 KB
s2.txt 1 ms 256 KB
s3.txt 1 ms 256 KB