# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1226651 | tgirolami09 | Let's Win the Election (JOI22_ho_t3) | Pypy 3 | 2597 ms | 52400 KiB |
nbStates = int(input())
nbVotesNeeded = int(input())
states = []
for i in range(nbStates):
vote,help = map(int,input().split())
states.append((vote,help))
bestTime = 10**10
for mask in range(2**nbStates+1):
if (mask.bit_count()>nbVotesNeeded):
continue
helpers = []
votes = []
for i in range(nbStates):
#set will get helper
if (mask & (1<<i) and states[i][1]!=-1):
helpers.append(states[i])
#unset will get vote
else:
votes.append(states[i])
helpers.sort(key=lambda x:x[1])
votes.sort()
currTime = 0
currVotes = 0
currHelpers = 1
for state in helpers:
currTime += state[1]/currHelpers
currVotes+=1
currHelpers+=1
if (currVotes<nbVotesNeeded):
for state in votes:
currTime += state[0]/currHelpers
currVotes+=1
if (currVotes==nbVotesNeeded):
break
bestTime = min(bestTime,currTime)
print(round(bestTime,3))
컴파일 시 표준 출력 (stdout) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |