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):
N=int(input())
l=list(map(int,input().split()))

a='Yes'
if N>1:
  for i in range(N-1):
    if l[i]=l[i+1]:
      continue
    elif l[i]<l[i+1]:
      l[i+1]-=1
    else:
      a='No'
    
print(a)

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

if N>=2:
  for i in range(N):
    if l[i]<=l[i+1]:
      continue
    elif l[i]==l[i+1]-1:
      l[i+1]=l[i+1]-1
    else:
      print('No')
        
print('Yes')

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

a='Yes'
before=0
if N>1:
  for i in range(N-1):
    if l[i]=l[i+1]:
      before=l[i+1]
    elif l[i]<l[i+1]:
      before=l[i+1]-1
    else:
      a='No'
    
print(a)

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

if N>=2:
  for i in range(N):
    if l[i]<=l[i+1]:
      continue
    elif l[i]+1==l[i+1]:
      l[i+1]-=1
    else:
      print('No')
        
print('Yes')

N=int(input())
list=list[map(int,input().split())]

x='Yes'
for i in range(N):
  if list[i]<=list[i+1]:
    continue()
  elif list[i]==list[i+1]+1:
    list[i+1]=list[i+1]+1
  else:
    x='No'
    
print(x)

N=int(input())
l=list[map(int,input().split())]

if N>=2:
  for i in range(N-1):
    if l[i]<=l[i+1]:
      continue
    elif l[i]==l[i+1]+1:
      l[i+1]=l[i+1]+1
    else:
        print('No')
        
print('Yes')

N=int(input())
list=list[map(int,input().split())]

x='Yes'
if N>=2:
  for i in range(N):
    if list[i]<=list[i+1]:
      continue
    elif list[i]==list[i+1]+1:
      list[i+1]=list[i+1]+1
    else:
        x='No'
    
print(x)

N=int(input())
l=list[map(int,input().split())]

if N>=2:
  for i in range(N):
    if l[i]<=l[i+1]:
      continue
    elif l[i]==l[i+1]+1:
      l[i+1]=l[i+1]+1
    else:
        print('No')
        
print('Yes

N=int(input())
list=[int(i) for i in str(input())]

x='Yes'
for i in range(N):
  if list[i]==list[i+1]:
    continue()
  elif list[i]==list[i+1]+1:
    list[i+1]=list[i+1]+1
  else:
    x='No'
    
print(x)

N=int(input())
l=list[map(int,input().split())]

if N>=2:
  for i in range(N-1):
    if l[i]<=l[i+1]:
      continue
    elif l[i]==l[i+1]+1:
      l[i+1]=l[i+1]+1
    else:
        print('No')
        
print('Yes

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

a='Yes'
for i in range(N-1):
  if l[i]=l[i+1]:
    continue
  elif l[i]<l[i+1]:
    l[i+1]-=1
  else:
    a='No'
    
print(a)

N=int(input())
list=[int(i) for i in str(input())]

x='Yes'
for i in range(N):
  if list[i]<=list[i+1]:
    continue()
  elif list[i]==list[i+1]+1:
    list[i+1]=list[i+1]+1
  else:
    x='No'
    
print(x)

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

if N>=2:
  for i in range(N-1):
    if l[i]<=l[i+1]:
      continue
    elif l[i]==l[i+1]-1:
      l[i+1]=l[i+1]-1
    else:
      print('No')
        
print('Yes')

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

befor=0
result='Yes'
for i in range(N):
  if i==0:
    before=l[i]-1
  else:
    if before < l[i]:
      before=l[i]-1
    elif before ==l[i]:
      before=l[i]
    else:
      result='No'
      
print('result')

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

a='Yes'
for i in range(N-1):
  if a[i]=a[i+1]:
    continue
  elif a[i]<a[i+1]:
    a[i+1]-=1
  else:
    a='No'
    
print(a)

n = int(input())
h = list(map(int, input().split()))
 
before = 0
result = 'Yes'
for i in range(len(h)):
    if i == 0:
        before = h[i] - 1
    else:
        if before < h[i]:
            before = h[i] - 1
        elif before == h[i]:
            before = h[i]
        else:
            result = 'No'
print(result)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted