結果
| 問題 |
No.2389 Cheating Code Golf
|
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2023-07-21 23:36:37 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 601 bytes |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-22 01:04:49 |
| 合計ジャッジ時間 | 3,100 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
n,m = map(int,input().split())
abp = [tuple(map(int,input().split())) for _ in range(n)]
ans = 0; f = []
for a,b,p in abp:
ans += 1/a
if a>b:
if p>1: f.append(((1/b-1/a)/(p-1),a,b,p))
else: ans += 1/b-1/a
f.sort(reverse=True); l = len(f); s = [0]*(l+1)
dp = [[0]*(m+1) for _ in range(l+1)]; dp[0][0] = 1
for i,(_,a,b,_) in enumerate(f): s[i+1] = s[i]+1/b-1/a
for i,(_,_,_,p) in enumerate(f):
for j in range(m):
dp[i+1][j] += dp[i][j]/p
dp[i][j+1] += dp[i][j]*(1-1/p)
for i in range(l): ans += s[i]*dp[i][m]
for j in range(m): ans += s[l]*dp[l][j]
print(ans)
ニックネーム