Math, asked by kanishakgupta1473, 1 year ago

Suppose we have a sequence of non-negative integers, namely a_1, a_2, ... ,a_n. At each time we can choose one term a_i with 0 < i < n and we subtract 1 from both a_i and a_i+1. We wonder whether we can get a sequence of all zeros after several operations.

Answers

Answered by pervaiz
0

f7virsoyc gd95dpuf f

Answered by joykinder485
0

Answer:

PYTHON SOLUTION FOR MODIFY SEQUENCE:-

n = int(input())

l = list(map(int,input().split()))

for i in range(n-1):

   if l[i]<=l[i+1]:

       l[i+1] = l[i+1]-l[i]

   else:

       print('NO')

       break

else:

   if l[n-1]==0:

       print('YES')

   else:

       print('NO')

Step-by-step explanation:

Similar questions