結果
| 問題 |
No.335 門松宝くじ
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:52:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,517 bytes |
| コンパイル時間 | 150 ms |
| コンパイル使用メモリ | 82,608 KB |
| 実行使用メモリ | 88,060 KB |
| 最終ジャッジ日時 | 2025-03-20 20:52:46 |
| 合計ジャッジ時間 | 3,883 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 TLE * 1 -- * 8 |
ソースコード
import itertools
def main():
import sys
input = sys.stdin.read
data = input().split()
idx = 0
N = int(data[idx])
idx += 1
M = int(data[idx])
idx += 1
tickets = []
for _ in range(M):
E = list(map(int, data[idx:idx+N]))
idx += N
tickets.append(E)
best = -1
max_exp = -1
for t_idx, E in enumerate(tickets):
max_pair = [[0]*(N+1) for _ in range(N+1)]
# Iterate all triplets i<j<k
for i, j, k in itertools.combinations(range(N), 3):
a = E[i]
b = E[j]
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 not in (a, c):
continue
# Update pairs (a, b), (a, c), (b, c)
pairs = [(a, b), (a, c), (b, c)]
for p, q in pairs:
if p == q:
continue
x, y = min(p, q), max(p, q)
if max_pair[x][y] < max_val:
max_pair[x][y] = max_val
# Compute expected value
total = 0
count = N * (N - 1) // 2
for x in range(1, N+1):
for y in range(x+1, N+1):
total += max_pair[x][y]
expected = total / count
if expected > max_exp or (expected == max_exp and t_idx < best):
max_exp = expected
best = t_idx
print(best)
if __name__ == "__main__":
main()
lam6er