結果
| 問題 | No.1792 科学の甲子園 | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 13:39:05 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,202 bytes | 
| コンパイル時間 | 518 ms | 
| コンパイル使用メモリ | 82,288 KB | 
| 実行使用メモリ | 77,544 KB | 
| 最終ジャッジ日時 | 2025-06-12 13:44:29 | 
| 合計ジャッジ時間 | 3,852 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 WA * 3 | 
ソースコード
import itertools
# Read input
n = int(input())
students = []
for idx in range(n):
    M, I, P, C, B, E = map(int, input().split())
    students.append((M, I, P, C, B, E, idx))
# Collect the top 5 students for each subject
candidate_set = set()
for subject in range(6):
    # Sort students by the current subject in descending order
    sorted_students = sorted(students, key=lambda x: -x[subject])
    # Take top 5
    top5 = sorted_students[:5]
    for student in top5:
        candidate_set.add(student)
# Convert the set to a list
candidates = list(candidate_set)
# If there are less than 4 candidates, which shouldn't happen as per constraints
if len(candidates) < 4:
    print(0)
    exit()
max_product = 0
# Iterate through all combinations of 4 candidates
for combo in itertools.combinations(candidates, 4):
    # Extract the subject values for each student in the combo
    m = max(s[0] for s in combo)
    i = max(s[1] for s in combo)
    p = max(s[2] for s in combo)
    c = max(s[3] for s in combo)
    b = max(s[4] for s in combo)
    e = max(s[5] for s in combo)
    
    product = m * i * p * c * b * e
    if product > max_product:
        max_product = product
print(max_product)
            
            
            
        