Created
August 22, 2018 20:04
-
-
Save rodoufu/1dc620544c852ef08eb15c102907e477 to your computer and use it in GitHub Desktop.
New Year Chaos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Complete the minimumBribes function below. | |
def minimumBribes(q): | |
soma = 0 | |
for i in xrange(len(q) - 1, -1, -1): | |
if q[i] - (i + 1) > 2: | |
print("Too chaotic") | |
return | |
for j in xrange(max(0, q[i] - 2), i): | |
soma += q[j] > q[i] | |
print soma | |
if __name__ == '__main__': | |
t = int(raw_input()) | |
for t_itr in xrange(t): | |
n = int(raw_input()) | |
q = map(int, raw_input().rstrip().split()) | |
minimumBribes(q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment