結果
問題 | No.335 門松宝くじ |
ユーザー |
![]() |
提出日時 | 2025-06-12 20:54:08 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,736 bytes |
コンパイル時間 | 209 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 87,960 KB |
最終ジャッジ日時 | 2025-06-12 20:58:03 |
合計ジャッジ時間 | 3,935 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 2 -- * 7 |
ソースコード
import sys def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 tickets = [] for _ in range(M): E = list(map(int, input[ptr:ptr+N])) ptr += N tickets.append(E) best_idx = 0 best_exp = -1.0 for idx, E in enumerate(tickets): max_prize = [[0]*(N+1) for _ in range(N+1)] # 1-based # Iterate all triplets i < j < k for i in range(N): a = E[i] for j in range(i+1, N): b = E[j] for k in range(j+1, N): c = E[k] max_val = max(a, b, c) min_val = min(a, b, c) mid_val = a + b + c - max_val - min_val if mid_val == a or mid_val == c: # Update pairs (a, b), (a, c), (b, c) pairs = [(a, b), (a, c), (b, c)] for x, y in pairs: if x == y: continue if x > y: x, y = y, x if max_prize[x][y] < max_val: max_prize[x][y] = max_val # Compute expected value total = 0 count = 0 for x in range(1, N+1): for y in range(x+1, N+1): total += max_prize[x][y] count += 1 expected = total / count if count != 0 else 0.0 if expected > best_exp or (expected == best_exp and idx < best_idx): best_exp = expected best_idx = idx print(best_idx) if __name__ == "__main__": main()