Submission #754349

# Submission time Handle Problem Language Result Execution time Memory
754349 2023-06-07T14:22:04 Z komalrajputtrootech Programming Contest (POI11_pro) Python 3
0 / 100
285 ms 24908 KB
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)
    # print("pairs", len(pairs))
    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())]
    # contestants = [[] for _ in range(n)]
    # code.interact(local=dict(globals(), **locals()))
    # for index, ele in enumerate(result):
    #     contestants[index].append(ele[1])

    # Sort the problems for each contestant based on penalty
    # for i in range(n):
        # contestants[i].sort(key=lambda x: (r, x), reverse=True)
        # contestants[i]
    # print("contestants", contestants)

    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, input().split())
n, m, r, t, k = map(int, sys.stdin.readline().split())
# pairs = [list(map(int, input().split())) for _ in range(k)]
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])
# print("result 2", result[2])
# print(*result[2], sep=",")
for assignment in result[2]:
    print(*assignment)
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 3028 KB It was possible to solve 100 problems and you solved only 47.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 3028 KB It was possible to solve 95 problems and you solved only 58.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 3284 KB It was possible to solve 80 problems and you solved only 9.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 5220 KB It was possible to solve 200 problems and you solved only 66.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 198 ms 18456 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 139 ms 15988 KB It was possible to solve 500 problems and you solved only 29.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 285 ms 24908 KB It was possible to solve 500 problems and you solved only 6.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 6112 KB It was possible to solve 390 problems and you solved only 93.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 17036 KB It was possible to get penalty of 500 points and you received 975673.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 7540 KB It was possible to solve 452 problems and you solved only 126.
2 Halted 0 ms 0 KB -