結果

問題 No.461 三角形はいくつ?
ユーザー pekempeypekempey
提出日時 2016-12-12 02:22:49
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 689 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 15,520 KB
最終ジャッジ日時 2024-05-07 01:05:41
合計ジャッジ時間 7,640 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
7,936 KB
testcase_01 AC 20 ms
7,936 KB
testcase_02 AC 21 ms
8,064 KB
testcase_03 AC 20 ms
7,936 KB
testcase_04 AC 324 ms
8,064 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

n = input()

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

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

f[1].sort()
f[2].sort()

ans = 0
for i in range(len(f[0])):
	k0 = len(f[2])

	while k0 > 0 and f[0][i] + f[2][k0 - 1] >= 1:
		k0 -= 1

	k1 = len(f[2])
	k2 = len(f[2])
	for j in range(len(f[1])):
		while k1 > 0 and f[1][j] + f[2][k1 - 1] >= 1:
			k1 -= 1
		while k2 > 0 and f[0][i] + f[1][j] + f[2][k2 - 1] >= 2:
			k2 -= 1
		if f[0][i] + f[1][j] < Fraction(1, 1):
			continue
		if k2 < len(f[2]) and f[0][i] + f[1][j] + f[2][k2] == 2:
			ans -= 1
		ans += len(f[2]) - max(k0, k1)
print(ans)
0