Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()

for i in range(1,n)[::-1]:
  if a[i]>a[i-1]+1:
    a[i-1]-=1
  elif a[i]==a[i-1]+1:
    continue
  else:
    print("No")
    sys.exit()

print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()
if len(a)==2 and a[0]<=a[1]:
  print("Yes")
  sys.exit()
else:
  print("No")
  sys.exit()
  
for i in range(1,n-1):
  if a[i+1] >= a[i] and a[i] >=a [i-1]:
    continue
  if a[i+1]>=a[i]-1 and a[i]-1>=a[i-1]:
    a[i]=a[i]-1
    continue
  elif i==1 and a[0]-1==a[1]:
    a[0]-=1
    continue
  else:
    print("No")
    sys.exit()
print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()

for i in range(1,n)[::-1]:
  print (i)
  if a[i]==a[i-1]:
    continue
  elif a[i]>a[i-1]:
    a[i]-=1
    continue
  else:
    print("No")
    sys.exit()

print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))
if n==0:
  print(Yes)
  sys.exit()
for i in range(1,n-1):
  if a[i+1] >= a[i] and a[i] >=a [i-1]:
    continue
  if a[i+1]>=a[i]-1 and a[i]-1>=a[i-1]:
    a[i]=a[i]-1
    continue
  else if i==1 and a[0]-1==a[1]:
    a[0]-=1
    continue
  else:
    print("No")
    sys.exit()
print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()

for i in range(1,n)[::-1]:
  if a[i]==a[i-1]:
    continue
  elif a[i]>a[i-1]:
    a[i]-=1
    continue
  else:
    print("No")
    sys.exit()

print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))

if n==0:
  print(Yes)
  sys.exit()
for i in range(1,n-1):
  if a[i+1]>=a[i] and a[i]>=a[i-1]:
    continue
  if a[i+1]>=a[i]-1 and a[i]-1>=a[i-1]:
    a[i]=a[i]-1
      continue
    else:
      print("No")
      sys.exit()
  else:
    print("No")
    sys.exit()
print("Yes")

 

import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()

for i in range(1,n)[::-1]:
  if a[i]>=a[i-1]:
    a[i-1]-=1
  elif a[i]a[i-1]:
    continue
  else:
    print("No")
    sys.exit()

print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))
print(a)
if n==0:
  print(Yes)
  sys.exit()
for i in range(1,n-1):
  print(i)
  if a[i+1] >= a[i] and a[i] >=a [i-1]:
    continue
  if a[i+1]>=a[i]-1 and a[i]-1>=a[i-1]:
    a[i]=a[i]-1
    continue
  else:
    print("No")
    sys.exit()
print("Yes")

 


import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()

for i in range(1,n)[::-1]:
  if a[i]>=a[i-1]:
    a[i-1]-=1
  elif a[i]==a[i-1]:
    continue
  else:
    print("No")
    sys.exit()

print("Yes")

import sys
n=int(input())
a=list(map(int,input().split()))
if len(a)==1:
  print("Yes")
  sys.exit()
if len(a)==2 and a[0]<=a[1]:
  print("Yes")
  sys.exit()
elif len(a)==2:
  print("No")
  sys.exit()
  
for i in range(1,n-1):
  if a[i+1]>=a[i]-1 and a[i]-1>=a[i-1]:
    a[i]=a[i]-1
    continue

  if a[i+1] >= a[i] and a[i] >=a [i-1]:
    continue
  else:
    print("No")
    sys.exit()
print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted