forked from geekbuti/Hackerrank-solution-in-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriple-sum.py
48 lines (31 loc) · 932 Bytes
/
triple-sum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/python3
import math
import os
import random
import re
import sys
from bisect import bisect_right
# Complete the triplets function below.
def triplets(a, b, c):
a = sorted(list(set(a)))
b = sorted(list(set(b)))
c = sorted(list(set(c)))
res = 0
for el in b:
left = bisect_right(a, el)
right = bisect_right(c, el)
print("left = {} el = {} right = {}".format(left, el, right))
res += left * right
return res
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
lenaLenbLenc = input().split()
lena = int(lenaLenbLenc[0])
lenb = int(lenaLenbLenc[1])
lenc = int(lenaLenbLenc[2])
arra = list(map(int, input().rstrip().split()))
arrb = list(map(int, input().rstrip().split()))
arrc = list(map(int, input().rstrip().split()))
ans = triplets(arra, arrb, arrc)
fptr.write(str(ans) + '\n')
fptr.close()