結果
| 問題 | No.1792 科学の甲子園 | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 13:41:31 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2,200 ms / 4,000 ms | 
| コード長 | 1,457 bytes | 
| コンパイル時間 | 255 ms | 
| コンパイル使用メモリ | 82,256 KB | 
| 実行使用メモリ | 77,528 KB | 
| 最終ジャッジ日時 | 2025-06-12 13:45:35 | 
| 合計ジャッジ時間 | 23,827 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
import sys
from itertools import combinations
def main():
    input = sys.stdin.read().split()
    ptr = 0
    N = int(input[ptr])
    ptr += 1
    students = []
    for _ in range(N):
        M = int(input[ptr])
        I = int(input[ptr + 1])
        P = int(input[ptr + 2])
        C = int(input[ptr + 3])
        B = int(input[ptr + 4])
        E = int(input[ptr + 5])
        ptr += 6
        students.append((M, I, P, C, B, E))
    
    k = 15  # 调整k的值
    
    top_students = set()
    subjects = [0, 1, 2, 3, 4, 5]
    for subject in subjects:
        indexed = [(students[i][subject], i) for i in range(N)]
        indexed.sort(reverse=True, key=lambda x: x[0])
        for j in range(min(k, len(indexed))):
            top_students.add(indexed[j][1])
    
    top_students = list(top_students)
    m = len(top_students)
    if m < 4:
        print(0)
        return
    
    max_score = 0
    for group in combinations(top_students, 4):
        M_max = max(students[i][0] for i in group)
        I_max = max(students[i][1] for i in group)
        P_max = max(students[i][2] for i in group)
        C_max = max(students[i][3] for i in group)
        B_max = max(students[i][4] for i in group)
        E_max = max(students[i][5] for i in group)
        
        score = M_max * I_max * P_max * C_max * B_max * E_max
        if score > max_score:
            max_score = score
    
    print(max_score)
if __name__ == '__main__':
    main()
            
            
            
        