結果
| 問題 | No.1792 科学の甲子園 | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 19:09:48 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,843 bytes | 
| コンパイル時間 | 537 ms | 
| コンパイル使用メモリ | 82,236 KB | 
| 実行使用メモリ | 77,952 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:09:52 | 
| 合計ジャッジ時間 | 3,548 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 WA * 3 | 
ソースコード
import sys
from itertools import combinations
def main():
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    students = []
    for _ in range(N):
        M = int(input[idx])
        I = int(input[idx+1])
        P = int(input[idx+2])
        C = int(input[idx+3])
        B = int(input[idx+4])
        E = int(input[idx+5])
        students.append((M, I, P, C, B, E))
        idx += 6
    # Indices for each subject: M, I, P, C, B, E
    subjects = [
        (0, [s[0] for s in students]),  # M
        (1, [s[1] for s in students]),  # I
        (2, [s[2] for s in students]),  # P
        (3, [s[3] for s in students]),  # C
        (4, [s[4] for s in students]),  # B
        (5, [s[5] for s in students]),  # E
    ]
    candidates = set()
    for subj_idx, scores in subjects:
        # Create a list of (student index, score)
        students_with_scores = list(enumerate(scores))
        # Sort by score descending, then by student index ascending to break ties
        students_sorted = sorted(students_with_scores, key=lambda x: (-x[1], x[0]))
        # Take top 5 students
        top5 = students_sorted[:5]
        for student in top5:
            candidates.add(student[0])
    candidates = list(candidates)
    if len(candidates) < 4:
        print(0)
        return
    max_product = 0
    for group in combinations(candidates, 4):
        m = max(students[i][0] for i in group)
        i = max(students[i][1] for i in group)
        p = max(students[i][2] for i in group)
        c = max(students[i][3] for i in group)
        b = max(students[i][4] for i in group)
        e = max(students[i][5] for i in group)
        product = m * i * p * c * b * e
        if product > max_product:
            max_product = product
    print(max_product)
if __name__ == '__main__':
    main()
            
            
            
        