結果
問題 |
No.461 三角形はいくつ?
|
ユーザー |
![]() |
提出日時 | 2020-04-08 16:19:24 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 732 bytes |
コンパイル時間 | 82 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-07-18 14:57:18 |
合計ジャッジ時間 | 7,059 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 -- * 39 |
ソースコード
#!/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))