結果
問題 |
No.461 三角形はいくつ?
|
ユーザー |
|
提出日時 | 2016-12-12 02:04:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 969 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 184,828 KB |
最終ジャッジ日時 | 2024-11-29 12:33:21 |
合計ジャッジ時間 | 113,391 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 13 TLE * 8 |
ソースコード
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, i) 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, i) if ps[2][j] == r: ans -= 1 else: ans -= 1 print(ans)