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 1224. Spiral

Why WA 5 help please
Posted by ivan228 14 Oct 2018 23:00
import sys
n,m=map(int,input().split())
n1=n
m1=m
j=0
ans=0
if n1==1 or m1 ==1:
    print(0)
    sys.exit()
while n1>0 and m1>0:
    if ans%2==0 and j!=0:
        if m1>0:
            m1-=1
            ans+=1
            j+=1
        else:
            print(ans)
            sys.exit()
    elif ans%2==1 and j!=0:
        if n1>0:
            n1-=1
            ans+=1
            j+=1
    else:
        n1-=1
        m1-=1
        ans+=1
        j+=1
print(ans)