~cpp def InputTestCaseNumber(): n = input('TestCaseNumber: ') print '----' return n def InputPeopleNumber(): n = input('PeopleNumber: ') return n def InputTheWeight(aN): list = [] sum = 0 for i in range(0, aN): list.append(input('Weight: ')); sum += list[i]; list.sort() return list, aN def MakeTwoTeams(aInfoTuple): a = 0 b = 0 for i in range(0, aInfoTuple[1]): if b < a: b += aInfoTuple[0][aInfoTuple[1]-1-i] else: a += aInfoTuple[0][aInfoTuple[1]-1-i] teamTuple = [a, b] teamTuple.sort() return teamTuple if __name__ == '__main__': testCaseNumber = InputTestCaseNumber() for i in range(0, testCaseNumber): print MakeTwoTeams(InputTheWeight(InputPeopleNumber())) print '----'