結果
| 問題 | No.1792 科学の甲子園 | 
| コンテスト | |
| ユーザー |  lam6er | 
| 提出日時 | 2025-04-15 23:29:29 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,212 bytes | 
| コンパイル時間 | 458 ms | 
| コンパイル使用メモリ | 82,372 KB | 
| 実行使用メモリ | 79,044 KB | 
| 最終ジャッジ日時 | 2025-04-15 23:30:32 | 
| 合計ジャッジ時間 | 4,139 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 WA * 3 | 
ソースコード
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))
# Collect top 5 indices for each subject
subjects = [0, 1, 2, 3, 4, 5]  # M, I, P, C, B, E
candidate_indices = set()
for subj in subjects:
    # Sort students by the subject's score in descending order, then by index ascending
    sorted_students = sorted(
        [(i, students[i][subj]) for i in range(n)],
        key=lambda x: (-x[1], x[0])
    )
    # Take top 5 indices
    top_indices = [i for i, val in sorted_students[:5]]
    candidate_indices.update(top_indices)
candidates = list(candidate_indices)
max_score = 0
# Generate all combinations of 4 students from candidates
for combo in itertools.combinations(candidates, 4):
    m_max = max(students[i][0] for i in combo)
    i_max = max(students[i][1] for i in combo)
    p_max = max(students[i][2] for i in combo)
    c_max = max(students[i][3] for i in combo)
    b_max = max(students[i][4] for i in combo)
    e_max = max(students[i][5] for i in combo)
    product = m_max * i_max * p_max * c_max * b_max * e_max
    if product > max_score:
        max_score = product
print(max_score)
            
            
            
        