Submission #1226430

#TimeUsernameProblemLanguageResultExecution timeMemory
1226430tgirolami09Let's Win the Election (JOI22_ho_t3)Pypy 3
11 / 100
2596 ms51492 KiB
#My brute-force for stress test
from itertools import permutations

nbStates = int(input())
nbVotesNeeded = int(input())

states = []

for i in range(nbStates):
    vote,help = map(int,input().split())

    states.append((vote,help))

#Three cases but in a case where we don't take a value there is another where that value is at the end and we cannot take it
#So only two
bestTime = 10**10
#We basically take the votes of all the states present
#But we do or don't take a helper
for perm in permutations(states,nbVotesNeeded):
    #Bitmask
    for mask in range(2**nbVotesNeeded+1):
        currHelpers = 1
        currTime = 0
        for i in range(nbVotesNeeded):
            #Set will go to the helper
            if (mask & (1<<i) and perm[i][1]!=-1):
                currTime += (perm[i][1]/currHelpers)
                currHelpers+=1

            #unset will go to the vote
            else:
                currTime += (perm[i][0]/currHelpers)
        

        if currTime<bestTime:
            bestTime = currTime
            # print(f"Best permutation is : {perm}, with mask {mask} (score {currTime})")

print(bestTime)

Compilation message (stdout)

Compiling 'Main.py'...

=======
  adding: __main__.pyc (deflated 27%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...