You are not logged in. Please login at www.codechef.com to post your questions!

×

WRONG WRONG WRONG : why I'm getting Wrong Answer even my code is correct ? - RAINBOWA

T=int(raw_input())
for i in range(T):
    N=int(raw_input())
    L=map(int,raw_input().split())
    sum1=0
    sum2=0
    answer =1 
    for j in range(N):
        if N%2==0 : 
            if j<=N/2-1 : 
                sum1=sum1+L[j]
            else :
                sum2=sum2+L[j]
            if j<N/2-1 :
               if L[j-1]!=L[j]-1 and L[j-1]!=L[j] :
                   answer = 0
            if j>N/2 :
                if L[j]!=L[j-1]-1 and L[j-1]!=L[j] :
                   answer = 0
        else :
            if j<N/2 :
                sum1=sum1+L[j]
            elif j>N/2 :
                sum2 = sum2+L[j]
            if j<N/2:
               if L[j-1]!=L[j]-1 and L[j-1]!=L[j] :
                   answer = 0
            if j>N/2 :
                if L[j]!=L[j-1]-1 and L[j-1]!=L[j] :
                   answer = 0  
    if answer == 0 or sum1!=sum2 :
        print "no"
    else :
        print "yes"

question link : https://www.codechef.com/problems/RAINBOWA

asked 20 Dec '18, 01:48

itssripriya's gravatar image

0★itssripriya
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×3,710
×1,901
×1,615
×846
×41

question asked: 20 Dec '18, 01:48

question was seen: 39 times

last updated: 20 Dec '18, 01:48