My issue
I am getting an EOF error in my code, thought I do not understand what might cause it
the problem input contains two lines and hence i was
My code
n = int(input())
strengths = input() # n space separated integers (12 9 10 4 ...)
# we take that as a string and split it
new_strengths = strengths.split(' ') # now its a list
teams = [] # 1,2,3 .... ,n
for i in range(1, n+1):
teams.append(i)
strength_team = {} # stores the strength of each team
for team in teams:
strength_team[team] = int(new_strengths[int(team) - 1])
matches = [] # all the possible matches
for team in teams:
i = team
while i != n:
matches.append([team, i+1])
i += 1
revenue = 0
for match in matches:
revenue += abs(strength_team.get(match[0]) - strength_team.get(match[1]))
print(revenue)
Problem Link: CodeChef: Practical coding for everyone