input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
import bisect n = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) cnt = 0 for b in B : a_cnt = len(A[:bisect.bisect_left(A,b)]) c_cnt = len(C[bisect.bisect_right(C,b):]) cnt += a_cnt * c_cnt ...
import bisect n = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) cnt = 0 for j in range(n) : a = bisect.bisect_left(A,B[j]) c = bisect.bisect_right(C,B[j]) cnt += a * (n-c) print(cnt)
p03557
import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() count = 0 for i in range(n): x = a[i] + 1 index1 = bisect.bisect_left(b, x) if index1 >= n: break b_tm...
import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() count = 0 for i in b: x = bisect.bisect_left(a, i) y = bisect.bisect_right(c, i) count += x * (len(c) - y) print(co...
p03557
n = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans=0 for a in A: for i in range(len(B)): if a < B[i]: for j in range(len(C)): if B[i] < C[j]: ...
n = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) import bisect ans = 0 for b in B: a = bisect.bisect_left(A,b) c = n - bisect.bisect_right(C,b) ans += a*c print(ans)
p03557
N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split()), reverse=True) counts = 0 checked = {} for _numB in B: if _numB in checked: counts += checked[_numB] else: countsA = 0 for _numA in A: ...
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) counts = 0 checked = {} for _numB in B: if _numB not in checked: countsA = bisect.bisect_left(A, _numB) countsC = bisect.bisect_right(C, ...
p03557
n=int(eval(input())) lists1=sorted(list(map(int,input().split()))) lists2=sorted(list(map(int,input().split()))) lists3=sorted(list(map(int,input().split())),reverse=True) lists_small=[] lists_big=[] for x in lists2: numbers=0 for y in lists1: if y<x: numbers+=1 if num...
n=int(eval(input())) lists1=sorted(list(map(int,input().split())))+[10**9+1] lists2=sorted(list(map(int,input().split())))+[10**9+2] lists3=sorted(list(map(int,input().split())))+[10**9+3] lists_small=[0]*(n+1) lists_big=[0]*(n+1) numbers=0 for x in range(n): while lists1[numbers]<lists2[x]: nu...
p03557
def lma():return list(map(int, input().split()))#x or y a = int(eval(input())) k=[] s=[] co=[0]*a*3 c=0 s= [lma()] x2= lma() x3 = lma() s.append(x2) s.append(x3) res =0 for j in range(3): for i in range(a): k.append([j,s[j][i]]) k.sort(key=lambda x: x[1], reverse=True) for i in range(a*3):...
def lma():return list(map(int, input().split()))#x or y a = int(eval(input())) k=[] s=[] c=0 s= [lma()] x2= lma() x3 = lma() s.append(x2) s.append(x3) res =0 r =0 for j in range(3): for i in range(a): k.append([j,s[j][i]]) k.sort(key=lambda x: x[1], reverse=True) for i in range(a*3): if...
p03557
import sys from heapq import heapify,heappop,heappush from collections import defaultdict read=sys.stdin.read readline=sys.stdin.readline def main(): n=int(readline()) a,b,c=(list(map(int,lst.split())) for lst in read().splitlines()) a.sort() b.sort() c=[-x for x in c] c.sort() ...
import sys from bisect import bisect_right,bisect_left read=sys.stdin.read readline=sys.stdin.readline def main(): n=int(readline()) a,b,c=(list(map(int,lst.split())) for lst in read().splitlines()) a.sort() b.sort() c=[-x for x in c] c.sort() print((sum(bisect_left(a,x)*bisect_...
p03557
N = int(input()) As = input().split(" ") Bs = input().split(" ") Cs = input().split(" ") As = [(int(i), 2) for i in As] Bs = [(int(i), 1) for i in Bs] Cs = [(int(i), 0) for i in Cs] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ...
N = int(input()) As = [(int(i), 2) for i in input().split(" ")] Bs = [(int(i), 1) for i in input().split(" ")] Cs = [(int(i), 0) for i in input().split(" ")] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ac += 1 elif i[1] ==...
p03557
N = int(input()) As = [(int(i), 2) for i in input().split(" ")] Bs = [(int(i), 1) for i in input().split(" ")] Cs = [(int(i), 0) for i in input().split(" ")] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ac += 1 elif i[1] ==...
N = int(input()) As = [(int(i), 2) for i in input().split(" ")] Bs = [(int(i), 1) for i in input().split(" ")] Cs = [(int(i), 0) for i in input().split(" ")] l = sorted(As + Bs + Cs) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ac += 1 elif i[1] == 1: bc += ac elif i...
p03557
import bisect n = int(eval(input())) a = sorted(list(map(int,input().split()))) b = sorted(list(map(int,input().split()))) c = sorted(list(map(int,input().split()))) d = [-1] * n ansum = 0 def stat(array,par): return bisect.bisect(array,par) for i in range(n): indexC = stat(c,b[i]) d[i] = max(0...
import bisect n = int(eval(input())) a = sorted(list(map(int,input().split()))) b = sorted(list(map(int,input().split()))) c = sorted(list(map(int,input().split()))) ansum = 0 for B in b: index = bisect.bisect_left(a,B) index2= bisect.bisect_right(c,B) ansum += index*(n-index2) print(ansum)
p03557
import bisect n = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) count = 0 a1 = sorted(a) b1 = sorted(b) c1 = sorted(c) for i in c1: prior_c = bisect.bisect_left(b1,i) prior_c_list = b1[:prior_c] for j in prior_c_li...
import bisect n = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a1 = sorted(a) c1 = sorted(c) count = 0 for i in b: count += bisect.bisect_left(a1,i) * (n - bisect.bisect_right(c1,i)) print(count)
p03557
N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) ans = 0 import bisect for i in A: a = bisect.bisect_right(B,i) for j in range(a,N): b = bisect.bisect_right(C,B[j]) ans += N-b print(...
N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) ans = 0 import bisect b = [] for i in B: x = bisect.bisect_right(C,i) b.append(N-x) y = sum(b) c = [y] for i in range(1,N): y -= b[i-1] c....
p03557
import bisect from sys import stdin N = int(eval(input())) lines = stdin.readlines l = [[int(i) for i in line.split()] for line in lines()] An = l[0] Bn = l[1] Cn = l[2] def main(): An.sort() Cn.sort() ans = 0 for Bi in Bn: # 以上 lx = bisect.bisect_left(An, B...
import bisect N = int(eval(input())) An = list(map(int, input().split())) Bn = list(map(int, input().split())) Cn = list(map(int, input().split())) def main(): A = sorted(An) C = sorted(Cn) ans = 0 for Bi in Bn: # 以上 lx = bisect.bisect_left(A, Bi) # より大き...
p03557
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = list(map(int, input().split())) Bn = list(map(int, input().split())) Cn = list(map(int, input().split())) A = sorted(An) C = sorted(Cn) print((sum(bisect_left(A, Bi...
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = list(map(int, input().split())) Bn = list(map(int, input().split())) Cn = list(map(int, input().split())) A = sorted(An) B = sorted(Bn) C = sorted(Cn) print((s...
p03557
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) print((sum([bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi i...
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = list(map(int, input().split())) Bn = list(map(int, input().split())) Cn = list(map(int, input().split())) A = sorted(An) B = sorted(Bn) C = sorted(Cn) print((s...
p03557
def main(): N = int(eval(input())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) def lowerBound(a, v): # 以上 return lb(a, 0, len(a), v) def upperBound(a, v): # より大きい # 値をプラス1 ...
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = sorted(map(int, input().split())) Bn = sorted(map(int, input().split())) Cn = sorted(map(int, input().split())) ans = 0 lx = 0 ux = 0 for Bi in Bn: # ...
p03557
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = sorted(map(int, input().split())) Bn = sorted(map(int, input().split())) Cn = sorted(map(int, input().split())) ans = 0 lx = 0 ux = 0 for Bi in Bn: # ...
N = int(eval(input())) An = sorted(map(int, input().split())) Bn = sorted(map(int, input().split())) Cn = sorted(map(int, input().split())) def f(xn, yn, zn): tn = [0] * N num = 0 j = N - 1 for i in range(N - 1, -1, - 1): while 0 <= j and xn[i] < yn[j]: num += zn[j]...
p03557
import itertools import math from collections import deque from collections import defaultdict from itertools import permutations import heapq import bisect INF = float("inf") N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A....
import itertools import math from collections import deque from collections import defaultdict from itertools import permutations import heapq import bisect INF = float("inf") N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A....
p03557
from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) r = 0 for i in range(N): ai = bisect_left(A, B[i]) ci = bisect_right(C, B[i]) r += len(A[:ai]) * len(C[ci:...
from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) r = 0 for i in range(N): ai = bisect_left(A, B[i]) ci = bisect_right(C, B[i]) r += ai * (N - ci) print(r)
p03557
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) bidx = 0 cidx = 0 abnums = [0] * (N+1) bcnums = [0] * (N+1) idx = 0 for i, a in enumerate(A): abnums[i+1] = a...
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() idxa = 0 idxc = 0 ans = 0 for b in range(N): while idxa < N and A[idxa] < B[b]: idxa += 1 while idxc < N and B[b] >= C[idxc]: ...
p03557
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a=sorted(a) b=sorted(b) c=sorted(c) c.insert(0,-1) c.append(10**10) B=[0]*n ans=0 for i in range(n): x=b[i] l=0 r=n+1 while r-l>1: m=(l+r)//2 if c[m]>x...
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a=sorted(a) b=sorted(b) c=sorted(c) c.insert(0,-1) c.append(10**10) a.insert(0,-1) a.append(10**10) ans=0 for i in range(n): x=b[i] l=0 r=n+1 while r-l>1: m=(l...
p03557
from collections import deque n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) q = deque() for i in a: q.append([i]) ans = 0 while q: now = q.popleft() n = len(now) if n == 3: ans += 1 elif ...
import bisect n = int(eval(input())) a = sorted(list(map(int, input().split()))) b = list(map(int, input().split())) c = sorted(list(map(int, input().split()))) ans = 0 for i in b: a_pos = bisect.bisect_left(a, i) c_pos = n - bisect.bisect_right(c, i) ans += a_pos * c_pos print(ans)
p03557
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: l = -1 r = N while r - l > 1: m = (r + l) // 2 if A[m] < b: l = m else: ...
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) def count_a(A, X): l = -1 r = N while r - l > 1: m = (r + l) // 2 if A[m] < b: l = m ...
p03557
from bisect import bisect_left, bisect N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A = sorted(A,reverse = False) C = sorted(C,reverse = False) cnt = 0 for i in B: #print( A[:bisect_left(A,i)],C[bisect(C,i):]) cnt +...
from bisect import bisect_left, bisect n=int(eval(input())) la=sorted(list(map(int,input().split()))) lb=list(map(int,input().split())) lc=sorted(list(map(int,input().split()))) ans=0 for i in lb: ans+=bisect_left(la,i)*(len(lc)-bisect(lc,i)) #iの挿入点つまりiより小さい値の数×(Cの総数- print(ans)
p03557
N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) from bisect import bisect_left, bisect ans = 0 for i in range(N): b = B[i] a = bisect_left(A,b) c = bisect(C,b) #print(b,A[:a],C[c:]) ...
N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) from bisect import bisect_left, bisect ans = 0 for i in range(N): b = B[i] a = bisect_left(A,b) c = bisect(C,b) #print(b,a,c) #print(...
p03557
# coding: utf-8 n = int(eval(input())) al = sorted(list(int(i) for i in input().split())) bl = sorted(list(int(i) for i in input().split())) cl = sorted(list(int(i) for i in input().split())) ans = 0 def low_left(a, key): left = -1 right = len(a) while right - left > 1: center = (left + ...
import bisect n = int(eval(input())) al, bl, cl = list(sorted(map(int, input().split())) for i in range(3)) ans = 0 for key in bl: top = bisect.bisect_left(al, key) btm = len(cl) - bisect.bisect_right(cl, key) ans += top * btm print(ans)
p03557
import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a = sorted(a) b = sorted(b) c = sorted(c) num_b = [0 for _ in range(n)] j = 0 for i in range(n): if j == n: num_b[i] = n continue w...
import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a = sorted(a) b = sorted(b) c = sorted(c) num_b = [0 for _ in range(n)] j = 0 for i in range(n): if j == n: num_b[i] = n continue w...
p03557
N=int(eval(input())) arr=[list(map(int,input().split())) for i in range(3)] count=0 for i in range(N): for j in range(N): if arr[0][i]<arr[1][j]: for k in range(N): if arr[1][j]<arr[2][k]: count+=1 print(count)
N=int(eval(input())) A,B,C=[list(sorted(map(int,input().split()))) for i in range(3)] count=0 def bs_l(lis,x): low,high=0,len(lis) while low<high: mid=(low+high)//2 if lis[mid]<x: low=mid+1 else: high=mid return low def bs_r(lis,x): ...
p03557
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) print((sum(len(A[:bisect.bisect_left(A, b)]) * len(C[bisect.bisect(C, b):]) for b in B)))
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) print((sum(bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B)))
p03557
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) ans = 0 for j in range(len(B)): axb = bisect.bisect_left(A, B[j]) bxc = len(C) - len(C[:bisect.bisect(C, B[j])]) ans += axb * bxc print(ans)
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = list(map(int, input().split())) C = sorted(map(int, input().split())) print((sum(bisect.bisect_left(A, B[j]) * (N - bisect.bisect(C, B[j])) for j in range(N))))
p03557
# -*- coding: utf-8 -*- """ Created on Sat Oct 20 10:21:00 2018 ABC077C @author: maezawa """ import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() cnt = 0 for ci in c: j = bise...
# -*- coding: utf-8 -*- """ Created on Sat Oct 20 10:21:00 2018 ABC077C @author: maezawa """ import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() bcnt = [0]*n for i, bi in enumerat...
p03557
N = int(eval(input())) A = [int(i) for i in input().split()] # 1 2 3 4 5 ... B = [int(i) for i in input().split()] # 1 2 3 4 5 ... C = [int(i) for i in input().split()] # 1 2 3 4 5 ... A.sort() B.sort() C.sort() #print(A) #print(B) #print(C) ##exit(0) ab=[0]*N bc=[0]*N b=N-1 c=N-1 count=0 while ...
N = int(eval(input())) A = [int(i) for i in input().split()] # 1 2 3 4 5 ... B = [int(i) for i in input().split()] # 1 2 3 4 5 ... C = [int(i) for i in input().split()] # 1 2 3 4 5 ... A.sort() B.sort() C.sort() #print(A) #print(B) #print(C) ##exit(0) ab=[0]*N bc=[0]*N b=N-1 c=N-1 count=0 while ...
p03557
import bisect n=int(eval(input())) a=[int(i) for i in input().split(" ")] b=[int(i) for i in input().split(" ")] c=[int(i) for i in input().split(" ")] b.sort() c.sort() lc=len(c) print((sum([sum([lc-bisect.bisect_right(c,j) for j in b[bisect.bisect_right(b,i):]]) for i in a]) ))
import bisect n=int(eval(input())) a=[int(i) for i in input().split(" ")] b=[int(i) for i in input().split(" ")] c=[int(i) for i in input().split(" ")] a.sort() c.sort() lc=len(c) print((sum([(lc-bisect.bisect_right(c,j))*(bisect.bisect_left(a,j)) for j in b])))
p03557
N = int(input().rstrip()) A = list(map(int, input().rstrip().split())) B = list(map(int, input().rstrip().split())) C = list(map(int, input().rstrip().split())) A.sort() B.sort() C.sort() def bin_search(vlist, targ): lb = -1 ub = len(vlist) while ub - lb > 1: mid = (lb + ub) // 2 ...
N = int(input().rstrip()) A = list(map(int, input().rstrip().split())) B = list(map(int, input().rstrip().split())) C = list(map(int, input().rstrip().split())) A.sort() C.sort() def bin_search_withR(vlist, targ): lb = -1 ub = len(vlist) while ub - lb > 1: mid = (lb + ub) // 2 ...
p03557
# ABC077C import bisect N=int(eval(input())) A=sorted(list(map(int,input().split()))) B=sorted(list(map(int,input().split()))) C=sorted(list(map(int,input().split()))) bC=[0 for i in range(N)] for i in range(N): bC[i]=N-bisect.bisect(C,B[i]) ans=0 for i in range(N): x=bisect.bisect(B,A[i]...
# ABC077C import bisect N=int(eval(input())) A=sorted(list(map(int,input().split()))) B=sorted(list(map(int,input().split()))) C=sorted(list(map(int,input().split()))) bC=[0 for i in range(N)] for i in range(N): bC[i]=N-bisect.bisect(C,B[i]) bCS=[0]*(N+1) for i in range(N): bCS[i+1] = bCS...
p03557
#二分探索 from bisect import bisect_left #input N = int(eval(input())) #print(N) A = sorted(list(map(int, input().split()))) #この表記について... B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) #print(A,B,C) #sort 昇順に並び替え #A.sort() #B.sort() #C.sort() Bis_B = [] for i in ra...
from bisect import bisect_left from bisect import bisect_right #input N = int(eval(input())) #print(N) A = sorted(list(map(int, input().split()))) #この表記について... B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) #print(A,B,C) #sort 昇順に並び替え #A.sort() #B.sort() #C.sort(...
p03557
import bisect N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() #print(A) #print(B) #print(C) ans = 0 for b in B: a = bisect.bisect_right(A, b-1) c = N - bisect.bisect_right(C, b) ...
import bisect n = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() C.sort() ans = 0 for b in B: a = bisect.bisect_right(A, b-1) c = len(C)-bisect.bisect_right(C, b) ans += a*c print(ans)
p03557
import bisect n = int(eval(input())) al = [int(a) for a in input().split()] bl = [int(b) for b in input().split()] cl = [int(c) for c in input().split()] al.sort() bl.sort() cl.sort() k = 0 for a in al: for b in bl[bisect.bisect_right(bl, a):]: k += n - bisect.bisect_right(cl, b) print(k)
import bisect n = int(eval(input())) al = [int(a) for a in input().split()] bl = [int(b) for b in input().split()] cl = [int(c) for c in input().split()] al.sort() bl.sort() cl.sort() k = 0 for b in bl: k += bisect.bisect_left(al, b) * (n - bisect.bisect_right(cl, b)) print(k)
p03557
n = int(input()) ais = list(map(int, input().split())) bis = list(map(int, input().split())) cis = list(map(int, input().split())) count = 0 ais.sort() bis.sort() cis.sort() for a in ais: i,j = 0,0 while(i < len(bis) and not(bis[i] > a)): i+=1 while(i < len(bis)): while(j < len(cis) and not(cis[j...
n = int(input()) ais = list(map(int, input().split())) bis = list(map(int, input().split())) cis = list(map(int, input().split())) count = 0 ais.sort() bis.sort() cis.sort() i,j = 0,0 for b in bis: while(i < len(ais) and ais[i] < b): i += 1 while(j < len(cis) and cis[j] <= b): j += 1 count +=...
p03557
N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) from bisect import bisect_left mids = [] for b in B: ind = bisect_left(A, b) mids.append(ind) cs = [0] for i in range(N): cs.append(cs[i]+...
N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) from bisect import bisect_left, bisect_right ans = 0 for b in B: ai = bisect_left(A, b) ci = bisect_right(C, b) ans += ai * (N-ci) print(ans)
p03557
import bisect N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) count = 0 # ソートして for c in C: under_c = bisect.bisect_left(B, c) for b in B[:under_c]: under_b = bisect.bisect_left(A, b) count ...
import bisect N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) count = 0 # ソートして for b in B: upeer_b = N - bisect.bisect_right(C, b) downer_b = bisect.bisect_left(A, b) count += upeer_b * downer_b ...
p03557
# coding: utf-8 import math N = int(eval(input())) a_list = [int(x) for x in input().split()] b_list = [int(x) for x in input().split()] c_list = [int(x) for x in input().split()] a_list.sort() b_list.sort() c_list.sort() a_lt_b_index = [N] * N i = j = 0 while (i < N and j < N): if (a_list[i] < b_list...
N = int(eval(input())) A_list = [int(a) for a in input().split()] B_list = [int(b) for b in input().split()] C_list = [int(c) for c in input().split()] A_list.sort() B_list.sort() C_list.sort() i = j = N-1 count_B_gt_A = [0] * N while i >= 0 and j >= 0: if B_list[i] > A_list[j]: count_B_gt_A[i]...
p03557
import bisect N = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a = sorted(a) b = sorted(b) c = sorted(c) z = [0] * N ans = 0 for i in range(N): e = b[i] cin = insert_index = bisect.bisect_right(c,e) z[i] = N-cin for i in ...
import bisect N = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a = sorted(a) b = sorted(b) c = sorted(c) z = [0] * N ans = 0 for i in range(N-1,-1,-1): e = b[i] cin = bisect.bisect_right(c,e) if i + 1 == N: z[i] = N-...
p03557
import bisect N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for mid in B: n_bottom = len(C[bisect.bisect_right(C,mid):]) n_top = len(A[:bisect.bisect_left(A,mid)]) ans += n_botto...
import bisect N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for mid in B: n_bottom = N - bisect.bisect_right(C,mid) n_top = bisect.bisect_left(A,mid) ans += n_bottom * n_top p...
p03557
N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) cnt = 0 for i in range(N): l, r = 0, 0 for j in range(N): k = i - j if(A[j] < B[i]): l += 1 if(B[i] < C[k]): r += 1 cnt += l*...
N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) a, c, cnt = 0, 0, 0 for b in B: while a < N and A[a] < b: a += 1 while c < N and C[c] <= b: c += 1 cnt += a * (N - c) print(cnt)
p03557
import math import copy import sys import fractions # import numpy as np # import statistics import decimal import heapq import collections import itertools import bisect # from operator import mul # sys.setrecursionlimit(100001) # input = sys.stdin.readline # sys.setrecursionlimit(10**6) # =...
import math import copy import sys import fractions # import numpy as np # import statistics import decimal import heapq import collections import itertools import bisect # from operator import mul # sys.setrecursionlimit(100001) # input = sys.stdin.readline # sys.setrecursionlimit(10**6) # =...
p03557
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: a_index = bisect.bisect_left(A, b) c_index = bisect.bisect_right(C, b) ans += len(A[:a_index])*len(C[c...
import bisect N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) ans = 0 for b in B: a_index = bisect.bisect_left(A, b) c_index = bisect.bisect_right(C, b) ans += a_index*(N-c_index) print(a...
p03557
# TODO: unknown n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() a.append(10 ** 9 + 1) b.append(10 ** 9 + 2) c.append(10 ** 9 + 3) ab = [0] * (n + 1) j = 0 for i in range(n + 1): while b[j]...
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() import bisect ans = 0 for j in range(n): i = bisect.bisect_left(a, b[j]) k = bisect.bisect_right(c, b[j]) ans += i * (n - k) prin...
p03557
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() import bisect ans = 0 for j in range(n): i = bisect.bisect_left(a, b[j]) k = bisect.bisect_right(c, b[j]) ans += i * (n - k) prin...
from bisect import bisect_left from itertools import accumulate n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() ba_cnt = [bisect_left(a, e) for e in b] ba_acm = [0] + list(accumulate(ba_cnt)) ...
p03557
from bisect import bisect_left as bl,bisect_right as br n=int(eval(input())) a,b,c=[sorted(list(map(int,input().split()))) for i in range(3)] ans=0 for v in b: if v<=a[0] or v>=c[-1]:continue ans+=bl(a,v)*(n-br(c,v)) print(ans)
from bisect import bisect_left as bl,bisect_right as br n=int(eval(input())) a,b,c=[sorted(list(map(int,input().split()))) for i in range(3)] print((sum(bl(a,v)*(n-br(c,v))for v in b)))
p03557
from bisect import bisect_left n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() cnt = 0 for i in range(n): num_c = c[i] b_idx = bisect_left(b,num_c) for j in range(b_idx): num_...
from bisect import bisect_left, bisect_right n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() len_c = len(c) total = 0 for num in b: idx_a = bisect_left(a, num) idx_c = bisect_right(c, num)...
p03557
# https://atcoder.jp/contests/abc077/tasks/arc084_a # C - Snuke Festival N = int(input().split()[0]) a_list = sorted(list(map(int, input().split()))) b_list = sorted(list(map(int, input().split()))) c_list = sorted(list(map(int, input().split()))) comb_n = 0 for i in range(N): # 10 ** 5 b = b_list[i]...
# https://atcoder.jp/contests/abc077/tasks/arc084_a # C - Snuke Festival import bisect N = int(input().split()[0]) a_list = sorted(list(map(int, input().split()))) b_list = sorted(list(map(int, input().split()))) c_list = sorted(list(map(int, input().split()))) comb_n = 0 comb_n_list = [] # 自分より大きい個数 st...
p03557
from bisect import bisect_right n = int(eval(input())) a = sorted(map(int, input().split())) b = sorted(map(int, input().split())) c = sorted(map(int, input().split())) cnt = 0 bn = [] for i in range(n): x2 = bisect_right(c, b[i]) bn.append(n-x2) for i in range(n): x1 = bisect_right(b, a[i]) ...
from bisect import bisect_right from bisect import bisect_left n = int(eval(input())) a = sorted(map(int, input().split())) b = sorted(map(int, input().split())) c = sorted(map(int, input().split())) cnt = 0 bn = [] for i in range(n): x1 = bisect_left(a, b[i]) x2 = bisect_right(c, b[i]) cnt += ...
p03557
import bisect import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort(reverse=True) # print(A) # print(B) # print...
import bisect import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: cnt_a = bisect.bisect_left(A,...
p03557
def n0():return int(eval(input())) def n1():return [int(x) for x in input().split()] def n2(n):return [int(eval(input())) for _ in range(n)] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] n=n0() a=n1() b=n1() c=n1() a.sort() b.sort() c.sort() from bisect import bisect_left,bisec...
def s0():return eval(input()) def s1():return input().split() def s2(n):return [eval(input()) for x in range(n)] def s3(n):return [[input().split()] for _ in range(n)] def n0():return int(eval(input())) def n1():return [int(x) for x in input().split()] def n2(n):return [int(eval(input())) for _ in range(n)] de...
p03557
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) D = len(C) ans = 0 for i in A: for k in B[bisect.bisect_right(B,i):]: ans += D - bisect.bisect_right(C,k) print(ans)
import bisect N = int(eval(input())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) ans = 0 for i in B: ans += bisect.bisect_left(A,i)*(N - bisect.bisect_right(C,i)) print(ans)
p03557
N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() def binary_search(lst, value, high): l = 0 r = N - 1 while l <= r: mid = (l + r) // 2 if lst[mid] < value: l = ...
#import generator N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) """ with open('generator.txt', 'r') as f: read = f.read().split('\n') N = int(read[0]) A = list(map(int, read[1].split())) B = list(map(int...
p03557
N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] A.sort() B.sort() C.sort() ans = 0 for i in B: OK = -1 NG = N while NG - OK > 1: mid = (OK + NG) // 2 if A[mid] < i: OK = m...
N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] A.sort() C.sort() ans = 0 def bisect(array, threshold, equal=False): OK = -1 NG = N while NG - OK > 1: mid = (OK + NG) // 2 if array[mid]...
p03557
n=int(eval(input())) a=list(map(int,input().split())) a.sort() b=list(map(int,input().split())) b.sort() c=list(map(int,input().split())) c.sort() ans=0 import bisect for bb in b: ao=bisect.bisect(a,bb-1) cnta=len(a[:ao]) cs=bisect.bisect(c,bb) cntc=len(c[cs:]) ans+=cnta*cntc print(ans)
n=int(eval(input())) a=list(map(int,input().split())) a.sort() b=list(map(int,input().split())) b.sort() c=list(map(int,input().split())) c.sort() ans=0 import bisect for i in range(n): x=bisect.bisect_left(a,b[i]) y=bisect.bisect_right(c,b[i]) ans+=x*(n-y) print(ans)
p03557
n = int(eval(input())) a = sorted([int(x) for x in input().split()]) b = sorted([int(x) for x in input().split()]) c = sorted([int(x) for x in input().split()]) def func1(list_1, list_2): res = [] cnt = 0 i = 0 for x in list_2: while i <= n-1 and list_1[i] < x: cnt += 1 ...
n = int(eval(input())) a = sorted([int(x) for x in input().split()]) b = sorted([int(x) for x in input().split()]) c = sorted([int(x) for x in input().split()]) res = 0 res_b = 0 cnt = 0 i, j = 0, 0 for c_ in c: while i <= n-1 and c_ > b[i]: while j <= n-1 and b[i] > a[j]: cnt += 1 ...
p03557
def main(): from bisect import bisect import sys sys.setrecursionlimit(200000) N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) ans = 0 for a in A: bIdx = bisect...
""" 前処理で下記のようなメモを作っておく必要がある。 candidate[j] -> 昇順ソートされたBの中でインデックスj以降のパーツを使えるときに、考えられるB,Cの組み合わせの数。 candidateリストを作成するためにまずは、下記のmemoを用意して、その総和としてcandidateを作成する。 memo[j] -> Bの中のインデックスjのパーツを使った場合に使用可能なCの数。 """ def main(): from bisect import bisect import sys sys.setrecursionlimit(200000) N = int(...
p03557
from bisect import bisect_left N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) """ まず、前処理として、「Bの祭壇から大きさb以下のパーツを使うとき、Aの祭壇のパーツとの組み合わせはいくつあるか」というのを調べてメモしておく。 次に、Cの祭壇の大きさがcのとき、という風に場合わけして、選べるBの祭壇の大きさを絞って、A,B,Cの組...
from bisect import bisect N = int(eval(input())) A = sorted(list(map(int,input().split()))) B = sorted(list(map(int,input().split()))) C = sorted(list(map(int,input().split()))) """ 前処理で、中部の祭壇でBi以下のサイズを選べるときの、中段と上段のパーツの組み合わせのパターン数を計算しておく。 """ BPattern = [] for i in range(N): b = B[i] idx = bisect(A...
p03557
from bisect import bisect_right def solve(): N, *ABC = list(map(int, open(0).read().split())) A = ABC[:N] B = ABC[N:2*N] C = ABC[2*N:] B.sort() C.sort() ans = 0 for i in range(N): index = bisect_right(B, A[i]) for j in range(index, N): an...
from bisect import bisect_left, bisect_right def solve(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for i in range(N): cnt_a = bisect_left(...
p03557
N=list(map(int,input().split())) A=sorted(list(map(int,input().split()))) B=list(map(int,input().split())) C=sorted(list(map(int,input().split()))) def countA(target,L): ok=-1 ng=len(L) while abs(ok-ng)>1: mid=(ok+ng)//2 if L[mid]<target: ok=mid else: ng=mid return (ok+1) ...
N=int(eval(input())) A=sorted(list(map(int,input().split()))) B=sorted(list(map(int,input().split()))) C=sorted(list(map(int,input().split()))) # Bの値を決める # Bより小さいAを二分探索、Bより大きいAを二分探索、その積を各Bごとに求めて足していく import bisect ans=0 for i in range(len(B)): apos=bisect.bisect_left(A,B[i]) cpos=bisect.bisect_right(C...
p03557
n = int(eval(input())) a = sorted(list(map(int,input().split()))) b = sorted(list(map(int,input().split()))) c = sorted(list(map(int,input().split()))) p = [0]*n q = [0]*n k = 0 for i in range(n): while k<n: if a[k]<b[i]: k += 1 else: break p[i] = k k = 0 for i in range(n): whi...
n = int(eval(input())) a = sorted(list(map(int,input().split()))) b = sorted(list(map(int,input().split()))) c = sorted(list(map(int,input().split()))) p = [0]*n q = [0]*n k = 0 for i in range(n): while k<n: if a[k]<b[i]: k += 1 else: break p[i] = k k = 0 s = 0 ans = 0 for i in ...
p03557
from bisect import * n=int(eval(input())) A=list(map(int,input().split())) B=list(map(int,input().split())) C=list(map(int,input().split())) A.sort() B.sort() C.sort() ans=0 for c in C: for b in B[:bisect_left(B,c)]: ans+=bisect_left(A,b) print(ans)
from bisect import * n=int(eval(input())) A=list(map(int,input().split())) B=list(map(int,input().split())) C=list(map(int,input().split())) A.sort() B.sort() C.sort() ans=0 for b in B: ans+=(n-bisect(C,b))*bisect_left(A,b) print(ans)
p03557
def binary_search_A(N,A,b): upper = N - 1 lower = 0 while upper - lower > 1: middle = upper + lower // 2 if A[middle] > b: upper = middle else: lower = middle if b >= A[upper]: return upper+1 elif b >= A[lower]: ...
def binary_search_low(ls, v): """ [input] ls: 二分探索するリスト(配列) v: 探索の基準となる値 [output] ok: 基準を満たす最大index (ng: 基準を満たさない最小index) """ ok = -1 ng = n while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if ls[mid] < v: ok = mid else: n...
p03557
def binary_search_low(ls, v): """ [input] ls: 二分探索するリスト(配列) v: 探索の基準となる値 [output] ok: 基準を満たす最大index (ng: 基準を満たさない最小index) """ ok = -1 ng = n while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if ls[mid] < v: ok = mid else: n...
def binary_search_low(ls, v): """ ・基準(v)より小さい値が配列の中に何個あるか, 二分探索によって見つける. [input] ls: 二分探索するリスト(配列) v: 探索の基準となる値 [output] return: 基準を満たす配列の要素数 """ ok = -1 ng = n while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if ls[mid] < v: ok = mid ...
p03557
n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: he=-1 ta=n while ta-he>1: mid=(he+ta)//2 if i>a[mid]: he=mid else: ta=mid x=he+1...
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: x=bisect.bisect_left(a,i) y=n-bisect.bisect_right(c,i) ans+=x*y print(ans)
p03557
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: x=bisect.bisect_left(a,i) y=n-bisect.bisect_right(c,i) ans+=x*y print(ans)
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: A=bisect.bisect_left(a,i) B=len(b)-bisect.bisect_right(c,i) ans+=A*B print(ans)
p03557
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=sorted(list(map(int,input().split()))) c=sorted(list(map(int,input().split()))) ans=0 for i in b: A=bisect.bisect_left(a,i) B=len(b)-bisect.bisect_right(c,i) ans+=A*B print(ans)
import bisect n=int(eval(input())) a=sorted(list(map(int,input().split()))) b=list(map(int,input().split())) c=sorted(list(map(int,input().split()))) ans=0 for i in b: ans+=(n-bisect.bisect_right(c,i))*bisect.bisect_left(a,i) print(ans)
p03557
import bisect ans = 0 N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() lis_B = [0] * N for i in range(N): tmp = bisect.bisect_right(C, B[i]) if tmp == N: break lis_B[i] = N - tmp for i ...
import bisect ans = 0 N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() for i in range(N): tmp_1 = bisect.bisect_right(C, B[i]) tmp_2 = bisect.bisect_left(A, B[i]) ans += (N - tmp_1) * tmp_2 pr...
p03557
def resolve(): import sys input = sys.stdin.readline # 整数 1 つ n = int(eval(input())) # 整数複数個 # a, b = map(int, input().split()) # 整数 N 個 (改行区切り) # N = [int(input()) for i in range(N)] # 整数 N 個 (スペース区切り) A = list(map(int, input().split())) B = list(map(int, input()....
def resolve(): import sys input = sys.stdin.readline # 整数 1 つ n = int(eval(input())) # 整数複数個 # a, b = map(int, input().split()) # 整数 N 個 (改行区切り) # N = [int(input()) for i in range(N)] # 整数 N 個 (スペース区切り) A = list(map(int, input().split())) B = list(map(int, input()....
p03557
import bisect n = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort() b.sort() c.sort() memo = [0]*(n+1) for i in range(n): memo[bisect.bisect_left(b,c[i])] += 1 for i in range(n-1,-1,-1): memo[i] += memo[i+1] for i in...
import bisect n = int(eval(input())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort() b.sort() c.sort() ans = 0 for i in range(n): t = b[i] ci = bisect.bisect_right(c,t) ai = bisect.bisect_left(a,t) ans += ai*(n-ci) print(ans...
p03557
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for a in A: i = bisect.bisect_right(B, a) for b in B[i:]: j = bisect.bisect_right(C, b) ans += N-j pri...
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() ans = 0 for b in B: i = bisect.bisect_left(A, b) j = bisect.bisect_right(C, b) ans += i*(N-j) print(ans)
p03557
def C_SnukeFestival(N, A, B, C): a = sorted(A) b = sorted(B) c = sorted(C) l = N ans = 0 for i in range(N): for j in range(N): for k in range(N): if a[i] < b[j] and b[j] < c[k]: ans += 1 return ans N = int(eval(input()))...
def C_SnukeFestival(N, A, B, C): a = sorted(A) b = sorted(B) c = sorted(C) import bisect ans = 0 for j in range(N): # b[j]より小さなaの要素の個数 i = bisect.bisect_left(a, b[j]) # b[j]より大きなcの要素の個数 k = N - bisect.bisect_right(c, b[j]) ans += i * k re...
p03557
import bisect import math N=int(eval(input())) b1=0 ans=0 A=list(map(int, input().split())) A=sorted(A) B=list(map(int, input().split())) B=sorted(B) C=list(map(int, input().split())) C=sorted(C) D=[] for b in B: D.append(len(C)-bisect.bisect_right(C,b)) B.append(math.inf) for i in range(...
import bisect N=int(eval(input())) b1=0 d=0 ans=0 A=list(map(int, input().split())) A=sorted(A) B=list(map(int, input().split())) B=sorted(B, reverse=True) C=list(map(int, input().split())) C=sorted(C) D=[] E=[] for b in B: d=d+len(C)-bisect.bisect_right(C,b) D.append(d) D=sorted(D, reve...
p03557
import bisect N = int(eval(input())) # サイズが下の方が大きくないとダメtop<mid<bottom tops = sorted(list(map(int, input().split(" ")))) mids = list(map(int, input().split(" "))) bottoms = sorted(list(map(int, input().split(" ")))) # print(tops) # print(mids) # print(bottoms) # def left_binary_search(check_list, num, left,...
N = int(eval(input())) tops = list(map(int, input().split())) middles = list(map(int, input().split())) bottoms = list(map(int, input().split())) tops.sort() middles.sort() bottoms.sort() # print(tops) # print(middles) # print(bottoms) # top<middle<bottomでないといけない # middleをfor文で繰り返して、topとbottomで二分探索をする。 # そし...
p03557
from sys import stdin def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() nums = [0] * (N + 1) ...
from sys import stdin def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() nums = [0] * (N + 1) ...
p03557
from sys import stdin def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() nums = [0] * (N + 1) ...
from sys import stdin from bisect import bisect_left def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort()...
p03557
from sys import stdin from bisect import bisect_right, bisect_left def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort()...
from sys import stdin from bisect import bisect_right, bisect_left def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort()...
p03557
from sys import stdin from bisect import bisect_right, bisect_left def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort()...
from sys import stdin from bisect import bisect_right, bisect_left def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort()...
p03557
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N, *ABC = list(map(int, read().split())) A = sorted(ABC[:N]) B = sorted(ABC[N : 2 * N]) C = sorted(ABC[2 * N : 3 * N]) ans = 0 ...
import sys from bisect import bisect_left, bisect_right read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N, *ABC = list(map(int, read().split())) A = sorted(ABC[:N]) B = ABC[N : 2 * N] C = sorted...
p03557
import sys from bisect import bisect_left, bisect_right read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N, *ABC = list(map(int, read().split())) A = sorted(ABC[:N]) B = ABC[N : 2 * N] C = sorted...
import sys from bisect import bisect_left, bisect_right read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N = int(readline()) A = list(map(int, readline().split())) B = list(map(int, readline().split()...
p03557
from sys import stdin from bisect import bisect_right, bisect_left def input(): return stdin.readline().strip() def main(): N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort()...
import sys from bisect import bisect_left, bisect_right read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N = int(readline()) A = list(map(int, readline().split())) B = list(map(int, readline().split()...
p03557
#ABC077 C - Snuke Festival from bisect import bisect_left, bisect_right si = lambda: eval(input()) ni = lambda: int(eval(input())) nm = lambda: list(map(int, input().split())) nl = lambda: list(map(int, input().split())) N = ni() A = nl() B = nl() C = nl() A.sort() B.sort() C.sort() ans = 0 for i in...
#ABC077 C - Snuke Festival from bisect import bisect_left, bisect_right si = lambda: eval(input()) ni = lambda: int(eval(input())) nm = lambda: list(map(int, input().split())) nl = lambda: list(map(int, input().split())) N = ni() A = nl() B = nl() C = nl() A.sort() C.sort() ans = 0 for i in range(N...
p03557
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() ans = 0 dict_a = dict() dict_b = dict() for i in range(n): if a[i] in list(dict_a.keys()): b_mid = dict_a[a[i]] else: le...
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() ans = 0 i = [] k = [] for j in range(n): left = n - 1 right = 0 a_mid = n // 2 while left >= right: if a[a_mid] >= b[j]...
p03557
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() ans = 0 i = [] k = [] for j in range(n): left = n - 1 right = 0 a_mid = n // 2 while left >= right: if a[a_mid] >= b[j]...
import bisect n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() ans = 0 for j in range(n): i = bisect.bisect_left(a, b[j]) k = n - bisect.bisect_right(c, b[j]) ans += i * k print(an...
p03557
def is_ok_under(array, mid, target): return array[mid] < target def is_ok_over(array, mid, target): return array[mid] > target # ok is -1. ng is len(array) def bSearchUnder(array, ok, ng, target): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok_under(array, mid, targe...
def binSearch(array, num): n = len(array) l = -1 r = n while l + 1 < r: m = (l + r) // 2 if num <= array[m]: r = m else: l = m return r n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())...
p03557
N = int(eval(input())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() ans = 0 for i in A: for j in B: for k in C: if (i<j)&(j<k): ans += 1 print(ans)
import bisect n= int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() ans = 0 for i in range(n): x = bisect.bisect_left(a,b[i]) y = bisect.bisect_right(c,b[i]) ans += x*(n-y) print(ans)
p03557
import bisect N = int(eval(input())) A = sorted([int(i) for i in input().split()]) B = sorted([int(i) for i in input().split()]) C = sorted([int(i) for i in input().split()]) cnt = 0 for i in range(N): x = bisect.bisect_right(B, A[i]) for j in B[x:]: y = bisect.bisect_right(C, j) c...
import bisect N = int(eval(input())) A = sorted([int(i) for i in input().split()]) B = sorted([int(i) for i in input().split()]) C = sorted([int(i) for i in input().split()]) cnt = 0 for b in B: cnt += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b)) print(cnt)
p03557
import bisect n = int(eval(input())) a = sorted(list(map(int, input().split()))) b = sorted(list(map(int, input().split()))) c = sorted(list(map(int, input().split()))) bnum = [n - bisect.bisect_right(c, b[i]) for i in range(n)] ans = 0 for i in range(n): ai = a[i] ans += sum(bnum[bisect.bisect_right(b, ...
import bisect n = int(eval(input())) a = sorted(list(map(int, input().split()))) b = sorted(list(map(int, input().split()))) c = sorted(list(map(int, input().split()))) ans = 0 for i in b: ai = bisect.bisect_left(a, i) ci = n - bisect.bisect_right(c, i) ans += ai*ci print(ans)
p03557
def biserch(l,key,flag=True): if flag is True: func = judge_1 else: func = judge_2 left = -1; right = len(l) while right - left > 1: middle = (left+right) // 2 if func(l,key,middle) is True: right = middle else: left = middle ...
def biserch_min(l,key): left = 0; right = len(l) while left < right: mid = (left+right)//2 if l[mid] < key: left = mid+1 else: right = mid return left def biserch_max(l,key): left = 0; right = len(l) while left < right: mid = (lef...
p03557
import bisect N = int(eval(input())) lst_a = sorted([int(x) for x in input().split()]) lst_b = sorted([int(x) for x in input().split()]) lst_c = sorted([int(x) for x in input().split()]) ans = 0 for b in lst_b: i = bisect.bisect_left(lst_a, b) j = bisect.bisect_right(lst_c, b) if i > 0 and j != l...
import bisect N = int(eval(input())) lst_a = sorted([int(x) for x in input().split()]) lst_b = sorted([int(x) for x in input().split()]) lst_c = sorted([int(x) for x in input().split()]) ans = 0 for b in lst_b: i = bisect.bisect_left(lst_a, b) j = bisect.bisect_right(lst_c, b) ans += i * (N - j) ...
p03557
import sys sys.setrecursionlimit(4100000) input=sys.stdin.readline # coding: utf-8 # Your code here! n=int(eval(input())) a = [list(map(int, input().split())) for _ in range(3)] a[0].sort() a[2].sort() """ print(a[0]) print(a[1]) print(a[2]) """ def bin_lower(b): if a[0][0]>=b: return 0 ...
import sys input = sys.stdin.readline # coding: utf-8 # Your code here! n = int(eval(input())) a = [list(map(int, input().split())) for _ in range(3)] a[0].sort() a[2].sort() def bin_chisaimono(b): if a[0][0] >= b: return 0 pl = 0 pr = n - 1 while True: pc = (pl + p...
p03557
import bisect n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort() b.sort() c.sort() ab=[] bc=[] for i in range(n): ab.append(bisect.bisect_left(a, b[i])) bc.append(bisect.bisect_left(b, c[i])) ans=0 for i in bc: ...
import bisect n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort() c.sort() ans=0 for i in b: up=bisect.bisect_left(a, i) dn=n-bisect.bisect_right(c, i) ans+=up*dn print(ans)
p03557
t = eval(input()) lst = list(map(int, input().split())) a = max(lst) b = min(lst) c = sum(lst) print((str(b) + " " + str(a) + " " + str(c)))
t = int(eval(input())) lst = list(map(int, input().split())) a = min(lst) b = max(lst) c = sum(lst) print((str(a) + " " + str(b) + " " + str(c)))
p02402
n = eval(input()) a = list(map(int,input().split())) a.sort() print(a[0],a[n-1],sum(a))
n = eval(input()) a = list(map(int,input().split())) print(min(a),max(a),sum(a))
p02402
eval(input()) nums = [int(x) for x in input().split(" ")] print(("{0} {1} {2}".format(min(nums), max(nums), sum(nums))))
line = eval(input()) nums = list(map(int, input().split())) print(f"{min(nums)} {max(nums)} {sum(nums)}")
p02402
from functools import reduce n = eval(input()) l = sorted(map(int,input().split())) print(l[0], l[n-1], reduce(lambda x,y: x+y, l))
n = eval(input()) l = list(map(int,input().split())) print(min(l), max(l), sum(l))
p02402