이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import sys
import time
def solve_team_programming_contest(n, m, r, t, k, pairs):
# Create a list of contestants with their available problems and penalty
pairs = sorted(pairs, reverse=True)
unique_second_values = set()
result = []
for pair in pairs:
if pair[1] not in unique_second_values:
unique_second_values.add(pair[1])
result.append(pair)
grouped_dict = {}
for ele in result:
if grouped_dict.get(ele[0]):
val = grouped_dict.get(ele[0])
val.append(ele[1])
grouped_dict.update({ele[0]: val})
else:
grouped_dict.update({ele[0]: [ele[1]]})
contenstants = [[key, grouped_dict[key]] for key in sorted(grouped_dict.keys())]
solved_problems = 0
penal_points = 0
assignments = []
# Assign problems to contestants
for i in range(len(contenstants)):
time = 0
for problem in contenstants[i][1]:
if time + r <= t:
solved_problems += 1
penal_points += time
assignments.append((contenstants[i][0], problem, time))
time += r
else:
break
penal_points = t - penal_points
assignments.sort(key=lambda x: x[2])
return solved_problems, penal_points, assignments
# Read input
n, m, r, t, k = map(int, sys.stdin.readline().split())
pairs = [list(map(int, sys.stdin.readline().split())) for _ in range(k)]
start = time.time()
# Solve the problem
result = solve_team_programming_contest(n, m, r, t, k, pairs)
# Print the result
print(result[0], result[1])
for assignment in result[2]:
print(*assignment)
end = time.time()
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |