結果

問題 No.461 三角形はいくつ?
ユーザー maspy
提出日時 2020-04-08 16:19:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 732 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 180,864 KB
最終ジャッジ日時 2024-07-18 14:58:06
合計ジャッジ時間 29,676 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 TLE * 4 -- * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools
from fractions import Fraction
from bisect import bisect_left, bisect_right

N = int(readline())
X = [[Fraction(0, 1)] for _ in range(3)]
m = map(int, read().split())
for p, a, b in zip(m, m, m):
    X[p].append(Fraction(b, a + b))

X.sort(key=len)
X[0].sort()
X[1].sort()
X[2].sort()


def solve(X, Y, Z):
    ret = 0
    for x, y in itertools.product(X, Y):
        if x + y > 1:
            continue
        cnt = bisect_right(Z, 1 - max(x, y))
        z = 1 - x - y
        cnt -= bisect_right(Z, z) - bisect_left(Z, z)
        ret += cnt
    return ret


print(solve(*X))
0