結果
| 問題 | No.1792 科学の甲子園 | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 13:36:16 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,566 bytes | 
| コンパイル時間 | 232 ms | 
| コンパイル使用メモリ | 82,688 KB | 
| 実行使用メモリ | 83,420 KB | 
| 最終ジャッジ日時 | 2025-06-12 13:42:19 | 
| 合計ジャッジ時間 | 7,223 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 TLE * 1 -- * 17 | 
ソースコード
import itertools
def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    N = int(data[0])
    students = []
    index = 1
    for _ in range(N):
        m = int(data[index])
        i_val = int(data[index+1])
        p = int(data[index+2])
        c = int(data[index+3])
        b = int(data[index+4])
        e = int(data[index+5])
        students.append((m, i_val, p, c, b, e))
        index += 6
    
    K = 20
    subject_indices = []
    for subj in range(6):
        temp = []
        for idx in range(N):
            val = students[idx][subj]
            temp.append((val, idx))
        temp.sort(reverse=True, key=lambda x: x[0])
        top_indices = [idx for (val, idx) in temp[:K]]
        subject_indices.append(top_indices)
    
    candidates = set()
    for top in subject_indices:
        for idx in top:
            candidates.add(idx)
    candidates = list(candidates)
    
    if len(candidates) < 4:
        print(0)
        return
    
    max_score = 0
    for combo in itertools.combinations(candidates, 4):
        max_m = max(students[i][0] for i in combo)
        max_i = max(students[i][1] for i in combo)
        max_p = max(students[i][2] for i in combo)
        max_c = max(students[i][3] for i in combo)
        max_b = max(students[i][4] for i in combo)
        max_e = max(students[i][5] for i in combo)
        product = max_m * max_i * max_p * max_c * max_b * max_e
        if product > max_score:
            max_score = product
    
    print(max_score)
if __name__ == "__main__":
    main()
            
            
            
        