結果
問題 | No.1792 科学の甲子園 |
ユーザー |
![]() |
提出日時 | 2025-04-15 23:32:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,212 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 81,584 KB |
実行使用メモリ | 78,900 KB |
最終ジャッジ日時 | 2025-04-15 23:33:24 |
合計ジャッジ時間 | 3,746 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)