$N$ sages are sitting around a round table with $N$ seats. Each sage holds chopsticks…
- User
sages are sitting around a round table with seats. Each sage holds chopsticks with his dominant hand to eat his dinner. The following happens in this situation.
- If sage is right-handed and a left-handed sage sits on his right, a level of frustration occurs to him. A right-handed sage on his right does not cause such frustration at all.
- If sage is left-handed and a right-handed sage sits on his left, a level of frustration occurs to him. A left-handed sage on his left does not cause such frustration at all.
Assistant
pythonimport itertools n = int(input()) a = list(map(int, input().split())) w = list(map(int, input().split())) elements = list(range(n)) if n == 0: print(0) exit() fixed = elements[0] min_total = float('inf') for perm in itertools.permutations(elements[1:]): current = [fixed] + list(perm) total = 0 for j in range(n): current_sage = current[j] right_neighbor = current[(j + 1) % n] if a[current_sage] == 0 and a[right_neighbor] == 1: total += w[current_sage] left_neighbor = current[(j - 1) % n] if a[current_sage] == 1 and a[left_neighbor] == 0: total += w[current_sage] if total < min_total: min_total = total print(min_total)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.