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 | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3408 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 153 |
| 2 | nik_exists | 151 |
| 3 | maroonrk | 150 |
| 4 | maspy | 149 |
| 5 | AmShZ | 146 |
| 6 | Um_nik | 143 |
| 7 | Errichto | 139 |
| 8 | adamant | 135 |
| 9 | BledDest | 134 |
| 10 | cry | 130 |
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 |
|---|


