TnT/Multi_CodeNet4Repair huggingface dataset:
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())
A = list(map(int, input().split()))
if N > 1:
    A[0] -= 1
    for i in range(1,N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


N = int(input())
A = list(map(int, input().split()))
if N > 1:
    for i in range(N-1):
        if A[i]>=A[i+1]:
            A[i] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


N = int(input())
A = list(map(int, input().split()))
if N > 1:
    A[i] -= 1
    for i in range(1,N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")

N = int(input())
A = list(map(int, input().split()))
if N > 1:
    for i in range(N-1):
        if A[i]>=A[i+1] && A[i] != 1:
            A[i] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


N = int(input())
A = list(map(int, input().split()))
if N > 1:
    A[0] -= 1
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
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())
list1=list(reversed(input().split()))
list2=list(map(int,list1))

for i in range(len(list2)):
    print(i)
    d=list2[i]-list2[i+1]
    if d==-1:
        list2[i+1]-=1
    if d<-1:
        print("No")
        break
    if i==len(list2)-2:
        print("Yes")
        break
#print(list2)

n=int(input())
list1=list(reversed(input().split()))
list2=list(map(int,list1))

if len(list2)==1:
    print("Yes")
else:
    for i in range(len(list2)):
        #print(i)
        d=list2[i]-list2[i+1]
        if d==-1:
            list2[i+1]-=1
        if d<-1:
            print("No")
            break
        if i==len(list2)-2:
            print("Yes")
            break
#print(list2)

Verdicts: Runtime Error

Accepted
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, heapq

N = int(input())
H = list(map(int, sys.stdin.readline().rsplit()))

pre = H[0] - 1
for i in range(1, N):
    h = H[i]
    if h - pre > 1:
        pre = h - 1
    elif h - pre == 1:
        pre = h
    elif h - pre == 0:
        pre = h + 1
    else:
        print("No")
        exit()

print("Yes")

import sys, heapq

N = int(input())
H = list(map(int, sys.stdin.readline().rsplit()))

pre = H[0] - 1
for i in range(1, N):
    h = H[i]
    if h - pre > 0:
        pre = h - 1
    elif h - pre == 0:
        pre = h
    else:
        print("No")
        exit()

print("Yes")

Verdicts: Wrong Answer

Accepted
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())
h = [int(i) for i in input().split()]
for i in range(n-1):
    if h[i]-h[i+1]==1:
        h[i] -= 1
h1 = sorted(h)
print(h)
print(h1)
if h==h1:
    print('Yes')
else:
    print('No')


n = int(input())
h = [int(i) for i in input().split()]
for i in range(n-1):
    if 0<=h[i]-h[i+1]<=1:
        h[i] -= 1
h1 = sorted(h)
if h==h1:
    print('Yes')
else:
    print('No')


n = int(input())
h = [int(i) for i in input().split()]
for i in range(n-1):
    if h[i]-h[i+1]<=1:
        h[i] -= 1
h1 = sorted(h)
if h==h1:
    print('Yes')
else:
    print('No')


n = int(input())
h = [int(i) for i in input().split()]
for i in range(n-1):
    if -1<=h[i]-h[i+1]<=1:
        h[i] -= 1
h1 = sorted(h)
if h==h1:
    print('Yes')
else:
    print('No')


n = int(input())
h = [int(i) for i in input().split()]
for i in range(n-1):
    if h[i+1]-h[i]<=1:
        h[i] -= 1
h1 = sorted(h)
if h==h1:
    print('Yes')
else:
    print('No')

n = int(input())
h = [int(i) for i in input().split()]
flag = 0
for i in range(n-1):
    if i==0:
        if h[i]-h[i+1]<=1:
            h[i] -=1
    else:
        if h[i-1]==h[i]:
            pass
        elif h[i-1]<h[i]:
            if h[i]-h[i+1]<=1:
                h[i]-=1
h1 = sorted(h)
if h==h1:
    print('Yes')
else:
    print('No')



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
_ = int(input())
h = [int(word) for word in input().split()]

prev_hi = h[0]
satisfies = False

for hi in h:
    if hi - 1 >= prev_hi:
        prev_hi = hi - 1
    elif hi >= prev_hi:
        prev_hi = hi
    else:
        break
else:
    satisfies = True

print('yes' if satisfies else 'no')


_ = int(input())
h = [int(word) for word in input().split()]

prev_hi = h[0]
satisfies = False

for hi in h:
    if hi - 1 >= prev_hi:
        prev_hi = hi - 1
    elif hi >= prev_hi:
        prev_hi = hi
    else:
        break
else:
    satisfies = True

print('Yes' if satisfies else 'No')


Verdicts: Wrong Answer

Accepted
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())
H = list(map(int,input().split()))
ans = "Yes"
for i in range(1,N):
    if H[i] > H[i-1]:
        H[i] += -1
for j in range(1,N):
    if H[j] > H[j-1]:
        ans = "No"
        break
print(ans)

N = int(input())
H = list(map(int,input().split()))
ans = "YES"
tmplist = [H[0]]
for i in range(1,N):
    tmp = H[i]
    if tmp >= max(tmplist)-1:
        tmplist.append(tmp)
    else:
        ans = "NO"
        break
print(ans)

N = int(input())
H = list(map(int,input().split()))
ans = "Yes"
for i in range(1,N):
    if H[i] < H[i-1]:
        H[i] += -1
for j in range(1,N):
    if H[j] < H[j-1]:
        ans = "No"
        break
print(ans)

N = int(input())
H = list(map(int,input().split()))
ans = "Yes"
for i in range(1,N):
    if H[i-1]+1 == H[i]:
        H[i] += -1
for j in range(1,N):
    if H[i] > H[i-1]:
        ans = "No"
        break
print(ans)

N = int(input())
H = list(map(int,input().split()))
ans = "Yes"
for i in range(1,N):
    if H[-i] < H[-i-1]:
        if H[-i]+1 == H[-i-1]:
            H[-i-1] += -1
        else:
            ans = "No"
            break
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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())
h_lis = list(map(int,input().split()))
for i in range(n-1):
  if h_lis[i+1]-h_lis[i] >= 2:
    print('No')
    break
else:
  print('Yes')



n = int(input())
h = list(map(int,input().split()))
h.reverse()
flg =True
for i in range(n-1):
  if h[i+1] > h[i]:
    h[i+1] -= 1
    if h[i+1] > h[i]:
      flg = False
    else:
      pass
  else:
    pass
if flg:
  print('Yes')
else:
  print('No')
  


    
    

Verdicts: Wrong Answer

Accepted
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())

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

i = 0

while i < n - 1:
    if h[i] <= h[i + 1]:
        i += 1
    elif h[i] - h[i + 1] == 1:
        h[i + 1] += 1
        i += 1
    else:
        break

if i == n - 1:
    print("YES") 
else:
    print("NO")

n = int(input())

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

i = n - 1

while i > 0:
    if h[i - 1] <= h[i]:
        i -= 1
    elif h[i - 1] - h[i] == 1:
        h[i - 1] -= 1
        i -= 1
    else:
        break

if i == 0:
    print("YES")
else:
    print("NO")

n = int(input())

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

i = n - 1

while i > 0:
    if h[i - 1] <= h[i]:
        i -= 1
    elif h[i - 1] - h[i] == 1:
        h[i - 1] -= 1
        i -= 1
    else:
        break

if i == 0:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
H = list(map(int, input().split()))

if N == 1:
  print('Yes')

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

      
      


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

if N == 1:
  print('Yes')

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

      
      


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

if N == 1:
  print('Yes')

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

      
      


Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
H = list(map(int, input().split()))

count = 0
flg = True

for i in range(len(H)):
  if i!=len(H) and H[i] > H[i+1]:
    H[i] -= 1
  if i!=0 and H[i-1] > H[i]:
    flg = False
    break

if flg==True:
  print('Yes')
else:
  print('No')


N = int(input())
H = list(map(int, input().split()))
 
hmax = H[-1]
 
for h in reversed(H):
  if h <= hmax:
    hmax = h
    continue
  if h-1 <= hmax:
    hmax = h-1
    continue
  print('No')
  quit()

print('Yes')

Verdicts: Runtime Error

Accepted
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())
arr = [int(x) for x in input().split(' ')]

pos = True

for i in range(1, n):
    if abs(arr[i] - arr[i-1]) > 1:
        pos = False
        break

if pos:
    print("Yes")
else:
    print("No")

n = int(input())
arr = [int(x) for x in input().split(' ')]

pos = True

for i in range(n-2, -1, -1):
    if(arr[i] > arr[i+1]):
        if(arr[i] - arr[i+1] > 1):
            pos = False
            break
        else:
            arr[i] = arr[i+1]

if pos:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

Accepted
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())
h = list(map(int,input().split()))
i = 1

while i < n:
    if h[i] < h[i-1]:
        h[i-1] -= 1
    elif h[i] > h[i-1]:
        h[i] -= 1
    else:
        pass

    i += 2

l = list(h)
l.sort()
if h == l:
    print('YES')
else:
    print('NO')

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

Verdicts: Wrong Answer

Accepted
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):
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
current = a[0]
good = True
for i in range(1,n):
    if a[i] < a[i-1]:
        good = False
        break
    if a[i] == a[i-1]:
        continue
    if a[i] > a[i-1]:
        a[i] = a[i] - 1
if good:
    print("Yes")
else:
    print("No")

import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
current = a[0]
good = True
for i in range(1,n):
    if a[i] < a[i-1]:
        good = False
        break
    if a[i] == a[i-1]:
        continue
    if a[i] > a[i-1]:
        a[i] = a[i] - 1
if good:
    print("Yes")
else:
    print("No")

Verdicts: Runtime Error

Accepted
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())
H = list(map(int, input().split()))

flag = "Yes"
for i in range(N-1,0,-1):
  print (i)
  if H[i-1] - H[i] > 1:
    flag = "No"
    break;
  elif H[i-1] - H[i] == 1:
    H[i-1] -= 1
for i in range(N-1):
  if H[i] - H[i+1] > 0:
    flag = "No"
    break;    
  
print (flag)


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

flag = "YES"
for i in range(N-1):
  if H[i] - H[i+1] > 1:
    flag = "NO"
    break;
  elif H[i] - H[i+1] == 1:
    H[i] -= 1
for i in range(N-1):
  if H[i] - H[i+1] > 0:
    flag = "NO"
    break;    
  
print (flag)

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

flag = "Yes"
for i in range(N-1,0,-1):
  if H[i-1] - H[i] > 1:
    flag = "No"
    break;
  elif H[i-1] - H[i] == 1:
    H[i-1] -= 1
for i in range(N-1):
  if H[i] - H[i+1] > 0:
    flag = "No"
    break;    
  
print (flag)


Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
h = list(map(int, input().split()))
cnt = h[0]
  
for i in range(n):
  if h[i] >= cnt-1:
    
    if h[i] >= cnt:
      cnt = h[i]
  else:
    print('No')
    exit()
  print(cnt)
print('Yes')


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

ans = []
for i in range(1,n+1):
  ans.append(i)

  

for i in range(n):
  for j in range(n):
    a[i] = p[j]
    a[j] = p[i]
    if a == ans:
      print('YES')
      exit()
    else:
      a = p
     
      
      
      
    
print('NO')

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

ans = []
for i in range(1,n+1):
  ans.append(i)

  

for i in range(n):
  for j in range(n):
    a[i] = p[j]
    a[j] = p[i]
    if a == ans:
      print('YES')
      exit()
    else:
      a = p
    print(p)    
      
      
      
    
print('NO')

n = int(input())
h = list(map(int, input().split()))
cnt = h[0]
  
for i in range(n):
  if h[i] >= cnt-1:
    
    if h[i] >= cnt:
      cnt = h[i]
  else:
    print('No')
    exit()
  
print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
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())
H = list(map(int, input().split()))
for i in range(N - 1, 0, -1):
	print(H[i], H[i - 1])
	if H[i] < H[i - 1] - 1:
		print('No')
		break
	elif H[i] == H[i - 1] - 1:
		H[i - 1] -= 1
else:
	print('Yes')


N = int(input())
H = list(map(int, input().split()))
for i in range(N - 1, 0, -1):
	if H[i] < H[i - 1] - 1:
		print('No')
		break
	elif H[i] == H[i - 1] - 1:
		H[i - 1] -= 1
else:
	print('Yes')


Verdicts: Wrong Answer

Accepted
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):
a = int(input())
b =list(input().split())
print(b)

c = 0
for i in range(a):
  if i>0:
    if (int(b[i]) - int(b[i-1])>1):
      c=1
if c==1:
  print("No")
else:
  print("Yes")

a = int(input())
b =list(input().split())
print(b)

c = 0
for i in range(a):
  if i>0:
    if (int(b[i-1]) - int(b[i])>1):
      c=1
if c==1:
  print("No")
else:
  print("Yes")

a = int(input())
b =list(map(int,input().split()))


c = 0

for i in range(a):
    if (b[i]-1)*(a-i)<=sum(b[i:a]):
      c+=1
      break
if c==0: print("Yes")
else: print("No")

a = int(input())
b =list(map(int,input().split()))

c = 0

for i in range(a):
  if i>0:
    if (b[i] - b[i-1])<-1:
      c+=2
    if (b[i] - b[i-1])==-1:
      c+=1
    if (b[i] - b[i-1])>0:
      c=0
  if c>=2: break
if c<=1: print("Yes")
else: print("No")

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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())
h = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
  if h[i] == h[i + 1] + 1:
    h[i] -= 1
  elif h[i] == h[i + 1]:
    pass
  else:
    print('No')
    exit()
print('Yes')

n = int(input())
h = list(map(int, input().split()))
for i in range(1, n - 1):
  if h[i] - h[i - 1] >= 2 or h[i - 1] > h[i]:
    print('No')
    exit()
print('Yes')

n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
  print(i)
  if h[i] == h[i + 1] + 1:
    h[i] -= 1
  elif h[i] - h[i + 1] >= 2:
    print('No')
    exit()
print('Yes')

n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
  if h[i] == h[i + 1] + 1:
    h[i] -= 1
  elif h[i] - h[i + 1] >= 2:
    print('No')
    exit()
print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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())
h=list(map(int,input().split()))
ans="Yes"
cngh=0
bkh=0
for i in range(n):
  if bkh>h[i]:
    if cngh!=h[i] and bkh==h[i]-1:
      cngh=h[i]-1
    elif (cngh!=h[i] and bkh!=h[i]-1) or (cngh==h[i] and cngh!=h[i]):
      ans="No"
      break
  bkh=h[i]
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans="Yes"
cngh=0
bkh=0
for i in range(n):
  if bkh>h[i]:
    if cngh!=h[i-1]:
      if bkh-1==h[i]:
      	cngh=h[i]
      else:
        ans="No"
        break
    else:
      if cngh!=h[i]:
        ans="No"
        break
  bkh=h[i]
print(ans)

Verdicts: Wrong Answer

Accepted
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())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1):
    if h[i]>=h[i+1]:
        h[i]-=1
for i in range(n-1):
    if h[i]>h[i+1]:
        ans="No"
        break
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans="Yes"
for i in range(n-1):
    if h[-i-1]<h[-i-2]:
        h[-i-2]-=1
        if h[-i-1]<h[-i-2]:
            ans="No"
            break
print(ans)

Verdicts: Wrong Answer

Accepted
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())
h = list(map(int, input().split()))

for i in range(1, len(h)):
    prev = h[i-1]
    curr = h[i]
    
    if prev <= curr:
        continue
    elif prev > curr + 1:
        print('No ')
        sys.exit()
    elif prev == curr + 1:
        continue
print('Yes ')



import sys

n = int(input())
h = list(map(int, input().split()))

max_num = 0
for num in h:
    max_num = max(max_num, num-1)
    if num < max_num:
        print('No')
        sys.exit()

print('Yes')

Verdicts: Wrong Answer

Accepted
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())
h = list(map(int, input().split()))


w = 1
for i in range(n-1):
    if h[i] - h[i+1] >= 2:
        w = 0

for j in range(n-2):
    if h[j] - h[j+1]  == 1:
        
        if h[j+1] - h[j+2] == 1:
            w =0
        else:
            count += 1
    elif h[j] - h[j+1] == 0:
        continue
        
if w == 0:
    print("No")
else:
    print("Yes")

n = int(input())
h = list(map(int,input().split()))

answer = "Yes"
for i in range(n-2,-1,-1):
    if h[i] > h[i+1] + 1:
        answer = "No"
        break
    elif h[i] == h[i+1] +1:
        h[i] -= 1

print(answer)

Verdicts: Runtime Error

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

    judge = 'Yes'

    H[0] = H[0] - 1

    for i in range(1,N):
        if H[i-1] > H[i] :
            H[i-1] = H[i-1] - 1

    for i in range(1,N):
        if H[i-1] > H[i]:
            judge = 'No'

    print(H)
    print(judge)

if __name__ == '__main__' :
    main()

def main():
    N = int(input())
    H = list(map(int, input().split()))

    judge = 'Yes'

    #H[0] = H[0] - 1

    for i in range(1,N):
        if H[i-1] > H[i] :
            H[i-1] = H[i-1] - 1
        elif H[i-1] == H[i] and H[i-2] != H[i-1]:
            H[i-1] = H[i-1] - 1

        

    for i in range(1,N):
        if H[i-1] > H[i]:
            judge = 'No'
        if N == 1:
            judge = 'Yes'

    #print(H)
    print(judge)

if __name__ == '__main__' :
    main()

Verdicts: Wrong Answer

Accepted
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())

h=list(map(int,input()))
if h[-1]==1:
    print("Yes")
else:
    print("No")


N = int(input())
H = list(map(int, input().split()))
v = -1
for h in H:
    if v > h:
        if v != h+1:
            print("No")
            exit()
        else:
            v = h+1
    else:
        v = h
print("Yes")


Verdicts: Runtime Error

Accepted
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):
print("No")

#-*-coding:utf-8-*-

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

differences=[]
for i in range(1,n):
    if lst[i]-lst[i-1]==0:
        continue
    elif lst[i]-lst[i-1]<=-2:
        print("No")
        sys.exit()
    else:differences.append(lst[i]-lst[i-1])


if len(differences)>=2:
    for i in range(len(differences)-1):
        if differences[i]==-1 and differences[i+1]==-1:
            print("No")
            sys.exit()
 
 
print("Yes")


Verdicts: Wrong Answer

Accepted
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())
h_list = list(map(int, input().split()))

ans = True

for i in range(n-1, 1, -1):
    if h_list[i] >= h_list[i-1]:
        continue

    else:
        h_list[i - 1] -= 1
        if h_list[i] >= h_list[i-1]:
            continue
        else:
            ans = False
            break

if ans == True:
    print('yes')
else:
    print('No')

n = int(input())
h_list = [int(h) for h in input().split()]
ans = True

for i in range(n-1, 0, -1):
    if h_list[i] >= h_list[i-1]:
        continue

    else:
        h_list[i - 1] -= 1
        if h_list[i] >= h_list[i-1]:
            continue
        else:
            ans = False
            break

if ans == True:
    print('yes')
else:
    print('No')

n = int(input())
h_list = [int(h) for h in input().split()]
ans = True

for i in range(n-1, 0, -1):
    if h_list[i] >= h_list[i-1]:
        continue

    else:
        h_list[i - 1] -= 1

        if h_list[i] >= h_list[i-1]:
            continue
        else:
            ans = False
            break

if ans is True:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
H = list(map(int, input().split()))
D = [0] * (N - 1)
judge = True
for i in range(N - 1):
    h1 = H[i]
    h2 = H[i + 1]
    d = h2 - h1
    D[i] = d
print(D)
for i in range(N - 2):
    d1 = D[i]
    d2 = D[i + 1]
    print(d1, d2)
    if d2 < 0:
        if d2 == -1:
            if d1 > 0:
                pass
            else:
                judge = False
                break
        else:
            judge = False
            break
if judge:
    print("Yes")
else:
    print("No")

N = int(input())
H = list(map(int, input().split()))
D = [0] * N
i = 0
judge = True
while i < N - 1:
    h1 = H[i]
    h2 = H[i + 1]
    if h2 - h1 < 0:
        if D[i] == 0:
            H[i] -= 1
            D[i] = 1
            i -= 1
            if i < 0:
                i == 0
        else:
            judge = False
            break

    else:
        i += 1

if judge:
    print("Yes")
else:
    print("No")


Verdicts: Wrong Answer

Accepted
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())
h=list(map(int,input().split()))
result='Yes'

if n == 2:
  if h[1] < h[0]:
    h[1] -=1
    if h[1] < h[0]:
      result='No'

if 3 <=n:
  for i in range(1, n-1):
    print(i)
    if h[i-1] <= h[i] and h[i] <= h[i+1]:
      continue
    else:
      h[i]-=1
      if h[i-1] <= h[i] and h[i] <= h[i+1]:
        continue
      else:
        result='No'
        break

print(result)

n=int(input())
h=list(map(int,input().split()))
result='Yes'

if 3 <=n:
  for i in range(1, n-1):
    print(i)
    if h[i-1] <= h[i] and h[i] <= h[i+1]:
      continue
    else:
      h[i]-=1
      if h[i-1] <= h[i] and h[i] <= h[i+1]:
        continue
      else:
        result='No'
        break

print(result)

n=int(input())
h=list(map(int,input().split()))
result='Yes'

if n == 2:
  if h[1] < h[0]:
    h[1] -=1
    if h[1] < h[0]:
      result='No'

for i in range(1, n-1):
  print(i)
  if h[i-1] <= h[i] and h[i] <= h[i+1]:
    continue
  else:
    h[i]-=1
    if h[i-1] <= h[i] and h[i] <= h[i+1]:
      continue
    else:
      result='No'
      break

print(result)

n=int(input())
h=list(map(int,input().split()))
result='Yes'
 
for i in range(n-1):
  if i==0:
    if h[1] < h[0]:
      h[0]-=1
    if h[1] < h[0]:
      result='No'
      break
  else:
    if h[i-1] <= h[i] and h[i] <= h[i+1]:
      if h[i-1] <= h[i]-1 and h[i]-1 <= h[i+1]:
        h[i]-=1
      continue
    else:
      h[i]-=1
      if h[i-1] <= h[i] and h[i] <= h[i+1]:
        continue
      else:
        result='No'
        break

if n == 2:
  if h[1] < h[0]:
    h[1]-=1
    if h[1] < h[0]:
      result='No'

print(result)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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())
h = input()
str_list = []
ans = "YES"
for i in range(len(h)):
  if(i % 2 == 0):
    str_list += h[i]

for j in range (len(str_list)-1):
  if(int(str_list[j]) > int(str_list[j]) + 1):
    str_list[j] = str(int(str_list[j])-1)
  if(int(str_list[j]) > int(str_list[j]) + 1):
    ans = "NO"
    break

print(ans)

n = int(input())
h = input()
str_list = []
ans = "Yes"
str_list = h.split(" ")

for j in range (len(str_list)-1):

  if(int(str_list[j]) < int(str_list[j+1])):
    str_list[j+1] = str(int(str_list[j+1])-1)
  elif(int(str_list[j]) > int(str_list[j+1])):
    ans = "No"
    break

print(ans)

Verdicts: Runtime Error

Accepted
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())
H = list(map(int, input().split()))

lis = list()
for i in range(len(H)-1):
    if H[i] - H[i+1] < -1:
        H[i+1] = H[i+1] - 1
        lis.append(1)
    else:
        lis.append(0)

if all(lis):
    print("Yes")
else:
    print("No")

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

lis = list()
for i in range(len(H)-1):
    if H[i] - H[i+1] <= -1:
        H[i+1] = H[i+1] - 1
        lis.append(1)
    else:
        lis.append(0)

if all(lis):
    print("Yes")
else:
    print("No")

N = int(input())
H = list(map(int,input().split()))
H_max = 0

for i in range(N-1):
    if H_max < H[i]:
        H_max = H[i]
    if H[i+1] < H_max - 1:
        print("No")
        break
else:
    print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Accepted
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())

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

for i in range(n-1):
    if hs[i] < hs[i + 1]:
        continue
    else:
        hs[i] = hs[i] - 1
        continue

if sorted(hs) == hs:
    print("Yes")
else:
    print("No")


n = int(input())

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

for i in range(n-1):
    if h[-i-2] - h[-i-1] >= 2:
        print("No")
        exit()
    elif h[-i-2] - h[-i-1] == 1:
        h[-i-2] = h[-i-2] - 1


print("Yes")

Verdicts: Wrong Answer

Accepted
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()))
l.append(10**9)
m = 'Yes'
for i in range(0,n-1)
  if l[n-i-1] <= l[n-i]:
    Continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    Break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)


n = int(input())
l = list(map(int,input().split()))
l.append(10**9)
m = 'Yes'
for i in range(0,n-1)
  if l[n-i-1] <= l[n-i]:
    continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)


n = int(input())
l = list(map(int,input().split()))
l.append(10**9)
m = 'Yes'
for i in range(0,n)
  if l[n-i-1] <= l[n-i]:
    Continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    Break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)

n = int(input())
l = list(map(int,input().split()))
l.append(1000000000)
m = 'Yes'
for i in range(0,n-1):
  if l[n-i-1] <= l[n-i]:
    continue
  elif l[n-i-1] > l[n-i] + 1:
    m = 'No'
    break
  else:
    l[n-i-1] = l[n-i-1] - 1

print(m)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
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):
-- [Char]あるいは String を Int にする
toInt :: (String -> Int)
toInt x = read x ::Int

--入力を受け取り、[Int]にする
getInts = do
  x <- getLine
  let y = (map$toInt)$words x -- 半角スペースで分割してInt にする
  return y

main = do
  _ <- getInts
  x <- getInts

  if ok x 0 == 1
    then putStrLn "Yes"
    else putStrLn "No"
  where
    ok x n =
      if null x
        then 1
        else if head x >= n
          then ok (tail x) $ max n $ (head x) - 1
          else 0


N = int(input())
H = [int(zz) for zz in input().split()][::-1]
p = H[0]

for i in range(N):
    if H[i] > p:
        H[i] -= 1
        if H[i] > p:
            print('No')
            exit()
    p = H[i]

print('Yes')

Verdicts: Runtime Error

Accepted
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
input = sys.stdin.readline
n = int(input())
hL = list(map(int, input().split()))

if hL==sorted(hL):
    print('Yes')
else:
    if max(hL)-min(hL)<=1:
        print('Yes')
    else:
        print('No')

import sys
import numpy as np
input = sys.stdin.readline
n = int(input())

L = np.array(list(map(int, input().split())))
print(L)

for i in range(n-1, 0, -1):
    if L[i]-L[i-1] ==-1:
        L[i-1] -=1

if np.all(L ==sorted(L)):
    print('Yes')
else:
    print('No')

import sys
n = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

for i in range(n-1, 0,-1):
    if H[i] - H[i-1] ==-1:
        H[i-1]-=1
        
        
if sorted(H) == H:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
stairs = [int(x) for x in input().split()]

minHeight = max(stairs[0] - 1, 0)

for i in stairs:
    if i < minHeight:
        result = False
        break
    else:
        if i > minHeight:
    	    minHeight = i - 1

if result:
    print("Yes")
else:
    print("No")

n = int(input())
stairs = [int(x) for x in input(). split()]
 
minHeight = max(stairs[0] - 1, 0)
result = True

for i in stairs:
    if i < minHeight:
        result = False
        break
    else:
        if i > minHeight:
    	    minHeight = i - 1
 
if result:
    print("Yes")
else:
    print("No")

Verdicts: Runtime Error

Accepted
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):
num = int(input())
arr = list(map(int,input().split()))
count = 0
for i in range(1,num):        

        
    if arr[i-1] > arr[i]:
        count += 1
    arr[i-1] -= 1
    
if count > 0:
    print("No")
else:
    print("Yes")

num = int(input())
arr = list(map(int,input().split()))
count = 0
for i in range(1,num):        
    arr[i-1] -= 1        
    if arr[i-1] >= arr[i]:
        count += 1
        break
    

    
if count > 0:
    print("No")
else:
    print("Yes")

num = int(input())
arr = list(map(int,input().split()))
count = 0
ans = 1
for i in range(num):
    if arr[i] > ans:
        ans = arr[i]
    
    elif arr[i] == ans:
        pass
    
    elif ans - arr[i] >=2:
        count +=1
        break

if count ==0:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
if N < 75000:
  print("No")

N = int(input())
if N < 50000:
  print("No")

print("No")

N = int(input())
if N < 50000
print("No")

N = int(input())
if N < 100000:
  print("No")

N = int(input())
hoge = input().split()
H = []
for i in range(N):
  H.append(int(hoge[i]) - 1)

dame = False
if N == 1:
  print("Yes")
else:
  for i in range(N-1,0,-1):
    huga = H[i] - H[i-1]
    if huga > 1:
      dame = True
      break
    elif huga == 1:
      H[i-1] = H[i-1] - 1
  if dame == True:
    print("No")
  else:
    print("Yes")

N = int(input())
hoge = input().split()
H = []
for i in range(N):
  H.append(int(hoge[i]))

piyo = True
dame = False
if N == 1:
  print("Yes")
else:
  for i in range(0,N-1):
    huga = H[i+1] - H[i]
    # print(huga)
    if huga < -1:
      dame = True
      break
    elif huga == -1:
      if piyo == True:
        H[i] = H[i] - 1
      piyo = True
    elif huga > 0:
      H[i+1] = H[i+1] - 1
      piyo = False
  # print(H)
  for i in range(0,N-1):
    huga = H[i+1] - H[i]
    # print(huga)
    if huga < 0:
      dame = True
      break
  if dame == True:
    print("No")
  else:
    print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
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())
h = [int(i) for i in input().split(' ')]
for i in range(n-1):
    if h[i] > h[i+1]-1:
            print('No')
            sys.exit()
    elif h[i] == h[i+1]-1:
        h[i+1] -= 1
    else:
        h[i] -= 1
print('Yes')

import sys
n = int(input())
h = [int(i) for i in input().split(' ')]
for i in range(n-1):
    if h[i] > h[i+1]-1:
            print('No')
            sys.exit()
    elif h[i] == h[i+1]-1:
        h[i+1] -= 1
print('Yes')

import sys
n = int(input())
h = [int(i) for i in input().split(' ')]
for i in range(n-1):
    if h[i] <= h[i+1]:
        if h[i] <= h[i+1] -1:
            h[i+1] -= 1
    elif h[i] > h[i+1]-1:
        print('No')
        sys.exit()


print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Accepted
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())
H = [int(i) for i in input().split()]
for i in range(N-1):
    if(i == N-2):
        if(H[i] + 1 == H[i+1] or H[i] == H[i+1]):
            H[i] == H[i+1]
        elif(H[i] <= H[i+1]):
            continue
        elif(H[i] + 1 > H[i+1]):
            print("No")
            exit()
    elif(H[i] + 1 == H[i+1] or H[i] == H[i+1]):
        H[i] == H[i+1]
    elif(H[i] <= H[i+1]):
        continue
    elif(H[i] + 1 > H[i+1]):
        print("No")
        exit()
    elif(H[i] > H[i+1] and H[i+1] > H[i+2]):
        print("No")
        exit()
print("Yes")

N = int(input())
H = [int(i) for i in input().split()]
for i in range(N-1,0,-1):
    if(H[i] < H[i-1]):
        H[i-1] -= 1
for i in range(N-1):
    if(H[i] > H[i+1]):
        print("No")
        exit()
print("Yes")

Verdicts: Wrong Answer

Accepted