Submission #31055621


Source Code Expand

Copy
import bisect
n = int(input())
a = sorted(list(map(int, input().split()))) #
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split()))) #
answer = 0
for i in range(n): # b[i]
max_j = bisect.bisect_left(a, b[i]) - 1 # a[j] < b[i] j
min_k = bisect.bisect_right(c, b[i]) # c[k] > b[i] k
answer += (max_j + 1) * (n - min_k)
print(answer)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import bisect
n = int(input())
a = sorted(list(map(int, input().split()))) # 予めソートしておく
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split()))) # 予めソートしておく
answer = 0
for i in range(n): # 中部を b[i] に決め打ち
    max_j = bisect.bisect_left(a, b[i]) - 1 # a[j] < b[i] なる最大の j
    min_k = bisect.bisect_right(c, b[i]) # c[k] > b[i] なる最小の k
    answer += (max_j + 1) * (n - min_k)
print(answer)

Submission Info

Submission Time
Task C - Snuke Festival
User Pro_ktmr
Language PyPy3 (7.3.0)
Score 300
Code Size 490 Byte
Status AC
Exec Time 227 ms
Memory 106140 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 32
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 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 AC 227 ms 104700 KB
02.txt AC 210 ms 104784 KB
03.txt AC 203 ms 101112 KB
04.txt AC 207 ms 101260 KB
05.txt AC 194 ms 103324 KB
06.txt AC 199 ms 103100 KB
07.txt AC 173 ms 103888 KB
08.txt AC 176 ms 103916 KB
09.txt AC 158 ms 103596 KB
10.txt AC 161 ms 103576 KB
11.txt AC 136 ms 100256 KB
12.txt AC 138 ms 100380 KB
13.txt AC 166 ms 104404 KB
14.txt AC 167 ms 104684 KB
15.txt AC 167 ms 104820 KB
16.txt AC 166 ms 104932 KB
17.txt AC 167 ms 104856 KB
18.txt AC 173 ms 104912 KB
19.txt AC 214 ms 104892 KB
20.txt AC 118 ms 98824 KB
21.txt AC 121 ms 99056 KB
22.txt AC 143 ms 106140 KB
23.txt AC 186 ms 104456 KB
24.txt AC 200 ms 104440 KB
25.txt AC 196 ms 104468 KB
26.txt AC 51 ms 61816 KB
27.txt AC 50 ms 61824 KB
28.txt AC 51 ms 61808 KB
29.txt AC 46 ms 61940 KB
s1.txt AC 51 ms 61904 KB
s2.txt AC 49 ms 61580 KB
s3.txt AC 53 ms 61736 KB


2025-04-05 (Sat)
17:07:36 +00:00