結果

問題 No.1792 科学の甲子園
ユーザー gew1fw
提出日時 2025-06-12 18:44:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 953 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 77,276 KB
最終ジャッジ日時 2025-06-12 18:45:00
合計ジャッジ時間 3,247 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n = int(input())
students = []
for _ in range(n):
    M, I, P, C, B, E = map(int, input().split())
    students.append((M, I, P, C, B, E))

pool = set()

# For each subject, add top 4 students' indices to pool
for s in range(6):
    subj_list = [(students[i][s], i) for i in range(n)]
    subj_list.sort(key=lambda x: (-x[0], x[1]))
    for i in range(4):
        if i >= len(subj_list):
            break
        pool.add(subj_list[i][1])

pool = list(pool)

max_product = 0

# Iterate all possible combinations of 4 indices from the pool
for quad_indices in itertools.combinations(pool, 4):
    quad_students = [students[idx] for idx in quad_indices]
    max_values = []
    for s in range(6):
        current_max = max(st[s] for st in quad_students)
        max_values.append(current_max)
    product = 1
    for mv in max_values:
        product *= mv
    if product > max_product:
        max_product = product

print(max_product)
0