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.
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | jiangly | 3631 |
| 4 | Kevin114514 | 3574 |
| 5 | maroonrk | 3521 |
| 6 | strapple | 3515 |
| 7 | Radewoosh | 3461 |
| 8 | tourist | 3428 |
| 9 | turmax | 3378 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 161 |
| 2 | adamant | 147 |
| 3 | Um_nik | 145 |
| 4 | Dominater069 | 142 |
| 5 | errorgorn | 140 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 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.
| Name |
|---|


