From c50d37dad38fbfa8cdec333b0da189c32a1c96a9 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Sat, 11 Jan 2025 13:03:16 +0000 Subject: [PATCH] solutions: 490A --- solutions/team_olympiad.py | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 solutions/team_olympiad.py diff --git a/solutions/team_olympiad.py b/solutions/team_olympiad.py new file mode 100644 index 0000000..44b9f67 --- /dev/null +++ b/solutions/team_olympiad.py @@ -0,0 +1,56 @@ +import sys + +n = int(input()) +skills = [int(x) for x in input().split(' ')] + +counts = [0, 0, 0] + +for i in range(3): + counts[i] = skills.count(i+1) + +if counts.count(0) == 0: + print(min(counts)) +else: + print("0") + sys.exit() + +def remove_extras(inp, bound): + counts = {} + return [ v if (counts.setdefault(v, 0) < bound and not counts.__setitem__(v, counts[v] + 1)) else 0 for v in inp ] +skills = remove_extras(skills, min(counts)) + +teams = [] +for _ in range(min(counts)): + team = [] + vals = [] + for idx,i in enumerate(skills): + if len(team) >= 3: + break + if i != 0 and i not in vals: + team.append(idx+1) + vals.append(i) + skills[idx] = 0 + teams.append(team) + +""" +teams = [] +for _ in range(min(counts)): + team = [] + for idx,i in enumerate(skills): + add = true + for j in teams: + if idx in j: + add = false + for j in team: + if j[0] == i: + add = false + if add: + team.append((i,idx)) + new_team = [] + for i in team: + new_team.append(i[1]) + teams.append(new_team) +""" + +for i in teams: + print(' '.join(str(d) for d in i))