結果
| 問題 |
No.335 門松宝くじ
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:51:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,650 bytes |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 81,640 KB |
| 実行使用メモリ | 61,248 KB |
| 最終ジャッジ日時 | 2025-06-12 20:56:16 |
| 合計ジャッジ時間 | 3,777 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | WA * 1 TLE * 1 -- * 8 |
ソースコード
import sys
def main():
import sys
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)
max_expected = -1
best_idx = 0
for idx, E in enumerate(tickets):
max_prize = {}
N_current = N
for i in range(N_current):
a = E[i]
for j in range(i + 1, N_current):
b = E[j]
for k in range(j + 1, N_current):
c = E[k]
sorted_vals = [a, b, c]
max_val = max(sorted_vals)
sorted_vals.remove(max_val)
second_max = max(sorted_vals)
if second_max in {a, c}:
m = max_val
key = (a, b)
if key not in max_prize:
max_prize[key] = 0
if m > max_prize[key]:
max_prize[key] = m
total = 0
count = N * (N - 1) // 2
for x in range(1, N + 1):
for y in range(x + 1, N + 1):
key = (x, y)
prize = max_prize.get(key, 0)
total += prize
expected = total / count if count != 0 else 0
if expected > max_expected:
max_expected = expected
best_idx = idx
elif expected == max_expected and idx < best_idx:
best_idx = idx
print(best_idx)
if __name__ == '__main__':
main()
gew1fw