Last active
August 22, 2018 20:04
-
-
Save rodoufu/058b2da00d838e4ed48a39423ec2743c 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