Pakgamer2022's blog

By Pakgamer2022, history, 23 months ago, In English

Hello CODEFORCES.
I have a problem in my code A of last Div.2 contest.
Help!

Code
Those who don't Help.

By the way CP is Getting harder and harder by the minute.
I propose to have div 4 contests every week.
See this Blog.

  • Vote: I like it
  • -14
  • Vote: I do not like it

| Write comment?
»
23 months ago, # |
  Vote: I like it +6 Vote: I do not like it

kid.

»
23 months ago, # |
Rev. 5   Vote: I like it +5 Vote: I do not like it
for _ in range(int(input())):
    n=int (input())
    l=list(map(int,input().split()))
    x=sum(l)
    if (x)==n:
        print(n-4)
    else:
        for i in range(n):
            if i!=n-1:
                if l[i]==-1 and l[i+1]==-1:
                    x+=4
                    break
        print(x)

You had written one more condition. You were thinking l[0] as the next index of l[-1].