Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #mozda e do mene ama nerealno tesko mi deluva, duri i da se pogodi dobro da se printa test caseo
- #ili sum preslab ili nema sansi vakvo nesto da se padni na ispit, i pak samo 4/5 test cases
- from constraint import *
- if __name__ == '__main__':
- n= int(input())
- team= Problem()
- participants= []
- participants_list= {}
- team_leaders_list= {}
- team_leaders= []
- for i in range(n):
- weight,letter= input().split(' ')
- participants_list[weight]=letter
- participants.append(float(weight))
- n = int(input())
- for i in range(n):
- weight,letter= input().split(' ')
- team_leaders_list[weight]=letter
- team_leaders.append(float(weight))
- variables= ["Team leader","Participant 1","Participant 2","Participant 3","Participant 4","Participant 5"]
- team.addVariable("Team leader",team_leaders)
- team.addVariables(["Participant 1","Participant 2","Participant 3","Participant 4","Participant 5"],(participants))
- team.addConstraint(AllDifferentConstraint())
- team.addConstraint(ExactSumConstraint(100.0),variables)
- result = team.getSolution()
- if(result is None):
- print("None")
- else:
- total_score=0
- for i in range(len(result)):
- total_score+=list(result.values())[i]
- print(f'Total score: {total_score}')
- for i in range(len(result)):
- if i == 0:
- print(f'{list(result.keys())[i]}: {list(team_leaders_list.values())[list(team_leaders_list).index(str(list(result.values())[i]))]}')
- else:
- print(f'{list(result.keys())[i]}: {list(participants_list.values())[list(participants_list).index(str(list(result.values())[i]))]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement