結果

問題 No.461 三角形はいくつ?
ユーザー ヒッキープログラミングするスレ GitHub ガチヒッキープログラミングするスレ GitHub ガチ
提出日時 2016-12-12 02:00:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 963 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 11,052 KB
実行使用メモリ 14,832 KB
最終ジャッジ日時 2023-08-19 17:56:50
合計ジャッジ時間 7,503 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
9,984 KB
testcase_01 AC 30 ms
9,964 KB
testcase_02 AC 30 ms
9,780 KB
testcase_03 AC 31 ms
9,740 KB
testcase_04 AC 109 ms
9,784 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
from bisect import bisect_left

n = int(input())

ps = [[Fraction(1)], [Fraction(1)], [Fraction(1)]]

for _ in range(n):
    p, a, b = map(int, input().split())
    ps[p].append(Fraction(a, a + b))

ps = list(map(sorted, ps))

ans = 0
for x in ps[0]:
    t = bisect_left(ps[1], Fraction(1) - x) 
    for c in range(t, len(ps[1])):
        y = ps[1][c]
        mn, mx = (x, y) if x < y else (y, x)
        k = Fraction(1) - mn
        i = bisect_left(ps[2], k)
        ans += len(ps[2]) - i
        if mn > Fraction(1, 2):
            r = (Fraction(1) - mn) + (Fraction(1) - mx)
            j = bisect_left(ps[2], r)
            if ps[2][j] == r:
                ans -= 1
        elif mn == Fraction(1) - mx:
            ans -= 1
        elif mn != mx:
            r = mn - (Fraction(1) - mx)
            j = bisect_left(ps[2], r)
            if ps[2][j] == r:
                ans -= 1
        else:
            ans -= 1

print(ans)
0