結果
| 問題 |
No.1792 科学の甲子園
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 13:04:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,152 bytes |
| コンパイル時間 | 273 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 75,648 KB |
| 最終ジャッジ日時 | 2025-05-14 13:06:31 |
| 合計ジャッジ時間 | 6,871 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 1 -- * 17 |
ソースコード
import sys
import itertools
# Function to solve the problem
def solve():
# Read the number of students N from standard input.
N = int(sys.stdin.readline())
# Read the aptitude values for each student.
# Store the student data as a list of lists, where each inner list contains
# the 6 aptitude values for one student.
students = []
for i in range(N):
# Read a line, split it into space-separated values, convert them to integers,
# and append the resulting list of 6 integers to the students list.
students.append(list(map(int, sys.stdin.readline().split())))
# Initialize the variable to keep track of the maximum score found so far.
# Start with 0, as scores are products of positive integers and will be >= 1.
max_score = 0
# Generate all possible combinations of 4 distinct student indices from the range [0, N-1].
# itertools.combinations is an efficient way to generate combinations.
# It takes an iterable (here, range(N)) and the size of combinations (here, 4).
# It yields tuples, each containing 4 distinct indices in increasing order.
for team_indices in itertools.combinations(range(N), 4):
# For each combination of 4 students (a potential team):
# Calculate the score for the current team. Initialize the score to 1.
# The score is the product of maximum aptitudes over all subjects.
current_score = 1
# Iterate through each of the 6 subjects (indexed 0 to 5).
for subject in range(6):
# Find the maximum aptitude value for the current subject among the selected 4 students.
max_subj_score = 0 # Initialize the max score for this subject within the team.
# Iterate through the indices of the students in the current team combination.
for student_idx in team_indices:
# Access the aptitude value of the student 'student_idx' for the current 'subject'.
# students[student_idx] gets the list of scores for the student.
# students[student_idx][subject] gets the score for the specific subject.
# Update max_subj_score if the current student's score is higher.
max_subj_score = max(max_subj_score, students[student_idx][subject])
# Multiply the team's total score by the maximum aptitude found for this subject.
# Since all aptitude values are guaranteed to be at least 1, the maximum aptitude
# for any subject will also be at least 1. Thus, current_score will remain positive.
current_score *= max_subj_score
# After calculating the total score for the current team, compare it with the
# overall maximum score found so far (max_score). Update max_score if the
# current team's score is greater.
max_score = max(max_score, current_score)
# After checking all possible teams of 4 students, print the overall maximum score found.
print(max_score)
# Call the solve function to execute the main logic of the program.
solve()
qwewe