• + 0 comments
    def getContestsInfo(contests):
        totalSum = 0
        impContests = 0
        for i in contests:
            totalSum = totalSum + i[0]
            if i[1] == 1:
                impContests = impContests + 1
        
        return [impContests, totalSum]
    
    def luckBalance(k, contests):
        info = getContestsInfo(contests)
        impContests, totalSum = info[0], info[1]
        contests = sorted(contests)
        winContests = impContests - k
        for i in contests:
            if winContests <= 0:
                break
            if i[1] == 1:
                totalSum = totalSum - (2*i[0])
                winContests = winContests - 1
        return totalSum