ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1005. Stone Pile

WA 4 (Python 3.6)
Posted by refk 29 May 2018 22:59
What's wrong?


import math
n=int(input())
allk=[int(i) for i in input().split()]
ans=s1=s2=0
for i in range(n):
    ans +=allk[i]

for i in range(n**2):
    s1=s2=0
    for k in range(n):
        if(i%2==0): s1 +=allk[k]
        else: s2 +=allk[k]
        i //=2
    k=math.fabs(s1-s2)
    ans=min(k,ans)
print(int(ans))
Re: WA 4 (Python 3.6)
Posted by Bogdan Devichev 3 Dec 2018 16:23
Why you used range(n**2)? Maybe range(2**n)?