From 20f7bd1e90b75adfbde9a2a5bdbda8db2f19efaf Mon Sep 17 00:00:00 2001 From: yenru0 Date: Tue, 23 Jul 2024 18:28:22 +0900 Subject: [PATCH] complete 5179.py --- zeta_python/completed/5179.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 zeta_python/completed/5179.py diff --git a/zeta_python/completed/5179.py b/zeta_python/completed/5179.py new file mode 100644 index 0000000..e8a93fa --- /dev/null +++ b/zeta_python/completed/5179.py @@ -0,0 +1,31 @@ +import sys + +input = sys.stdin.readline + +if __name__ == "__main__": + T = int(input()) + for tc in range(1, T + 1): + M, N, P = map(int, input().split()) + + counts = [[0 for _ in range(M)] for _ in range(P)] + scores = [[0 for _ in range(M)] for _ in range(P)] + solved = [0 for _ in range(P)] + for _ in range(N): + p, m, t, j = input().split() + p, t, j = int(p) - 1, int(t), int(j) + m = ord(m) - 65 + if j == 0: + counts[p][m] += 1 + else: + if scores[p][m] != 0: + continue + else: + solved[p] += 1 + scores[p][m] = counts[p][m] * 20 + t + + sumscore = [(solved[p], -sum(scores[p]), p) for p in range(P)] + sumscore.sort(reverse=True) + print(f"Data Set {tc}:") + for s in sumscore: + print(f"{s[2] + 1} {s[0]} {-s[1]}") + print()