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
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
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)]
# 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)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
18724 KB |
It was possible to solve 100 problems and you solved only 52. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
18264 KB |
It was possible to solve 95 problems and you solved only 61. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
19668 KB |
It was possible to solve 80 problems and you solved only 10. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
21416 KB |
It was possible to solve 200 problems and you solved only 67. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
104 ms |
30292 KB |
It was possible to solve 494 problems and you solved only 8. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
100 ms |
28032 KB |
It was possible to solve 500 problems and you solved only 30. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
126 ms |
32840 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
65 ms |
21396 KB |
It was possible to solve 390 problems and you solved only 97. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
122 ms |
29912 KB |
It was possible to get penalty of 500 points and you received 976208. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
65 ms |
22312 KB |
It was possible to solve 452 problems and you solved only 127. |
2 |
Halted |
0 ms |
0 KB |
- |