You are viewing a single comment's thread. Return to all comments →
n = int(input())
x = list(map(int, input().split()))
unique_rooms = set(x)
captain_room = (sum(unique_rooms) * n - sum(x)) // (n - 1)
print(captain_room)
This is the best answer
Seems like cookies are disabled on this browser, please enable them to open this website
The Captain's Room
You are viewing a single comment's thread. Return to all comments →
Input group size
n = int(input())
Input the list of room numbers
x = list(map(int, input().split()))
Use a set to extract unique room numbers
unique_rooms = set(x)
Use the mathematical approach to calculate the Captain's room
captain_room = (sum(unique_rooms) * n - sum(x)) // (n - 1)
Output the Captain's
print(captain_room)
This is the best answer