結果
| 問題 | No.1623 三角形の制作 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-23 22:40:06 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,095 ms / 2,000 ms | 
| コード長 | 1,280 bytes | 
| コンパイル時間 | 156 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 116,740 KB | 
| 最終ジャッジ日時 | 2024-07-18 18:42:50 | 
| 合計ジャッジ時間 | 13,124 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 19 | 
ソースコード
import sys
#sys.setrecursionlimit(1000000)
input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
import itertools
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e10)
mod = int(1e9+7)
n = int(input())
r = sorted(list(Counter(lmp()).items()))
g = sorted(list(Counter(lmp()).items()))
b = [(-inf,0)]+sorted(list(Counter(lmp()).items()))+[(inf, 0)]
bc = [0]
for i in range(1,len(b)):
    bc.append(bc[-1]+b[i][1])
ans = 0
#print(bc)
for i,u in r:
    for j,v in g:
        if i < j:break
        L,R = 0,len(b)-1
        while (R-L) != 1:
            m = (R+L)//2
            if b[m][0] <= i-j:
                L = m
            else:
                R = m
        #print(L,R)
        LL,RR = 0,len(b)-1
        while (RR-LL) != 1:
            #print(LL,RR)
            m = (RR+LL)//2
            if b[m][0] <= i:
                LL = m
            else:
                RR = m
        #print(i,j,bc[L],bc[RR])
        # L = bisect.bisect_right(b,i-j)
        # R = bisect.bisect_right(b,i)
        ans += max(0,(bc[LL]-bc[L]))*u*v
print(ans)
            
            
            
        