結果
問題 | No.1792 科学の甲子園 |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:19:21 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,421 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,144 KB |
実行使用メモリ | 77,000 KB |
最終ジャッジ日時 | 2025-03-20 21:20:41 |
合計ジャッジ時間 | 7,003 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 TLE * 1 -- * 17 |
ソースコード
import itertoolsdef main():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))k = 20candidates = set()# For each subject (0 to 5), collect top k students' indicesfor subject in range(6):# Create list of tuples (-score for descending order, index)subject_scores = [ (-students[i][subject], i) for i in range(n) ]# Sort by score ascending (which is descending when score is negated)subject_scores.sort()# Take top k entriesfor i in range(min(k, n)):idx = subject_scores[i][1]candidates.add(idx)candidates = list(candidates)if len(candidates) < 4:print(0)returnmax_product = 0# Iterate over all combinations of 4 students from candidatesfor group in itertools.combinations(candidates, 4):m = max(students[i][0] for i in group)info = 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 * info * p * c * b * eif product > max_product:max_product = productprint(max_product)if __name__ == "__main__":main()