Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def satisfyeverybody(k,rounds):
- #we play k rounds, then the person i can play i rounds.Then he can supervise k-i(rounds)
- #total supervisor position sum(k-rounds[i]) over all i
- supervisors = sum(map(lambda x: k - x, rounds))
- return supervisors >= k
- def minimum_rounds():
- n=int(input())
- rounds=list(map(int,input().strip().split()))
- if len(rounds)<=1:
- return 0
- lower_bound=0
- upper_bound=sum(rounds)
- answer=sum(rounds)
- while lower_bound<=upper_bound:
- mid=(lower_bound+upper_bound)//2
- if (satisfyeverybody(mid,rounds)):
- answer=mid
- upper_bound=mid-1
- else:
- lower_bound=mid+1
- return answer
- print(minimumMafiaRounds())
Add Comment
Please, Sign In to add comment