Please share any resources for the title. I’m writing this because I couldn’t solve yesterday’s Problem C as SortedList wasn’t available in the Python compilers.
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | turmax | 3559 |
| 6 | tourist | 3541 |
| 7 | strapple | 3515 |
| 8 | ksun48 | 3461 |
| 9 | dXqwq | 3436 |
| 10 | Otomachi_Una | 3413 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 147 |
| 4 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 141 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
Please share any resources for the title. I’m writing this because I couldn’t solve yesterday’s Problem C as SortedList wasn’t available in the Python compilers.
def IL():
return [int(i) for i in input().split()]
def I():
return input()
n, c = IL()
from collections import defaultdict
G = defaultdict(list)
deg = [0] * n
for _ in range(c):
a, b = IL()
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
deg[a] += 1
deg[b] += 1
exp = IL()
isolated_sum = sum(exp[i] for i in range(n) if deg[i] == 0)
nodes = [i for i in range(n)]
def dfs(node, taken):
if node == n:
return 0
if deg[nodes[node]] == 0:
return dfs(node + 1, taken)
res = dfs(node + 1, taken)
if all(not taken[nei] for nei in G[nodes[node]]):
taken[nodes[node]] = True
res = max(res, exp[nodes[node]] + dfs(node + 1, taken))
taken[nodes[node]] = False
return res
result = isolated_sum + dfs(0, [False] * n)
print(result, end="")
Problem Statement: Two developers who hate each other cannot be on the same team. The graph represents the connections between the developers, where if developer X hates developer Y, then Y also hates X and we have to form a team with maximum experience given in exp array. This is a bi-directional relationship.
| Название |
|---|


