This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
n, m, r, t, k = map(int, input().split())
problems_solved = [0] * n
time_remaining = [t] * m
contestant_assigned = [-1] * m
starting_time = [-1] * m
for _ in range(k):
a, b = map(int, input().split())
a -= 1 # Adjust index to 0-based
b -= 1 # Adjust index to 0-based
contestant_assigned[b] = a
for problem in range(m - 1, -1, -1):
for contestant in range(n):
if contestant_assigned[problem] == -1 and time_remaining[problem] >= r:
if contestant in range(n) and problem in range(m):
problems_solved[contestant] += 1
time_remaining[problem] -= r
contestant_assigned[problem] = contestant
starting_time[problem] = t - time_remaining[problem]
break
total_penal_points = sum(starting_time)
print(sum(problems_solved), total_penal_points)
for problem in range(m):
if starting_time[problem] != -1:
print(contestant_assigned[problem] + 1, problem + 1, starting_time[problem])
# | 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... |