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

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

flg = 0

if len(H) != 1:
    for i in range(0, len(H)-1, 1):
        if H[i] > H[i+1]:
            H[i]=H[i]-1

check_list = sorted(H)

if check_list==H:
    print("YES")
else:
    print("NO")


N = int(input())

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

flg = 0

if len(H) != 1:
    for i in range(0, len(H)-2, 1):
        num_0 = H[i]
        num_1 = H[i+1]
        num_2 = H[i+2]

        if (num_0 >= num_1) and (num_1 > num_2):
            print("NO")
            flg = 1
            break


if flg == 0:
    print("YES")


N = int(input())

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

flg = 0

for i in range(0, len(H)-2, 1):
    num_0 = H[i]
    num_1 = H[i+1]
    num_2 = H[i+2]

    if (num_0 > num_1) and (num_1 > num_2):
        print("NO")
        flg = 1
    
if flg == 0:
    print("YES")



N = int(input())

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


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

check_list = sorted(H)

if check_list==H:
    print("Yes")
else:
    print("No")



N = int(input())

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

flg = 0

if len(H) != 1:
    for i in range(0, len(H)-1, 1):
        if H[i] > H[i+1]:
            H[i]=H[i-1]

check_list = H.sort()

if check_list==H:
    print("YES")
else:
    print("NO")


N = int(input())

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

flg = 0

if len(H) != 1:
    for i in range(0, len(H)-2, 1):
        num_0 = H[i]
        num_1 = H[i+1]
        num_2 = H[i+2]

        if (num_0 >= num_1) and (num_1 > num_2):
            print("NO")
            flg = 1


if flg == 0:
    print("YES")


N = int(input())

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

flg = 0

if len(H) != 1:
    for i in range(0, len(H)-2, 1):
        num_0 = H[i]
        num_1 = H[i+1]
        num_2 = H[i+2]

        if (num_0 > num_1) and (num_1 > num_2):
            print("NO")
            flg = 1

if flg == 0:
    print("YES")



N = int(input())

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


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

check_list = sorted(H)

if check_list==H:
    print("Yes")
else:
    print("No")



N = int(input())

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

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

    check_list = sorted(H)

    if check_list==H:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

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

FLAG = True
for i in range(N):
  current = H[i-1]
  for j in range(i, N):
    if ( (current-H[j-1])>1):
      FLAG = False
      break;
      
if(FLAG == True):
  print("Yes")
else:
  print("No")

N = int(input())
list = input().split()
H = [int(x) for x in list]
 
FLAG = True
current = H[N-1]
for i in reversed(range(N-1)):
  if(H[i]-1 > current):
    FLAG = False
    break
  elif(H[i]-1 == current):
    H[i] = H[i] -1
  else:
    H[i] = H[i]
  current = H[i]
  
if(FLAG == True):
  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
flag = 0
while i < N:
    if H[i-1] > H[i]:
        if H[i-1] - 1 >= H[i] and flag == 0:
            H[i-1] = H[i-1] + 1
            flag = 1
        else:
            print("No")
            quit()
    i += 1
print("YES")

N = int(input())
H = list(map(int, input().split(' ')))
i = 1
a = 0
while i < N:
    if H[i-1] <= H[i]-1:
        H[i] = H[i] - 1
    i += 1
i = 1
while i < N:
    if H[i-1] > H[i]:
        print("No")
        quit()
    i += 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())
*H, = map(int, input().split())
current = 0
for h1, h2 in zip(H, H[1:]):
    diff = h1 - h2
    if diff > 1 or (diff == 1 and current == h1): print('No'); break;
    current = h2
else:
    print('Yes')

N = int(input())
*H, = map(int, input().split())
for i in range(N-1, 0, -1):
    h1, h2 = H[i-1], H[i]
    if h1 <= h2: continue
    elif h1 == h2 + 1: H[i-1] -= 1
    else: print('No'); break;
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):
N = int(input())
k = list(map(int, input().split()))
base = k[0]
ans = "Yes"
max = 0

for i in range(1, N):
  print(str(base-1))
  print(k[i])
  if base-1 >= max:
    max = base -1;
  print("-----------")
  if (base-1 <= k[i]) and (max <= k[i]):
    pass
  else:
    ans = "No"
    break
  base = k[i]
    
print(ans)

N = int(input())
k = list(map(int, input().split()))
base = k[0]
ans = "Yes"
max = 0

for i in range(1, N):
  #print(str(base-1))
  #print(k[i])
  if base-1 >= max:
    max = base -1;
  #print("-----------")
  if (base-1 <= k[i]) and (max <= k[i]):
    pass
  else:
    ans = "No"
    break
  base = k[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()))
if n == 1:
    print('Yes')
for i in range(n-1):
    if h[i]>h[i+1]+1:
        print('No')
        break
    if i > 0:
        if (h[i]-1==h[i-1]) or (h[i]==h[i-1]-1):
            if h[i]==h[i+1]+1:
                print('No')
                break
    if i == n-2:
        print('Yes')

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

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

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

n=int(input())
h=list(map(int, input().split()))
h.reverse()
a=0
for i in range(len(h)-1):
  if h[i]+1 < h[i+1]:
    a+=1
    break
  elif h[i]+1==h[i+1]:
    h[i+1]=h[i+1]-1
  else:
    pass
if a==0:
  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 = [int(h) for h in input().split()]

if N == 1:
    ans = "Yes"
else:
    c = 1
    while c <= N-2:
        if H[c] > H[c+1] and H[c-1] < H[c]:
            H[c] -= 1
        elif H[c] == H[c+1] and H[c-1] < H[c]:
            H[c] -= 1
            H[c+1] -= 1
            c += 1
        c += 1
    List = []
    for j in range(N):
        List.append(H[j])
    List.sort()
    if List == H:
        ans = "Yes"
    else:
        ans = "No"

print(ans,List)

N = int(input())
H = [int(h) for h in input().split()]

ans = "Yes"
for i in range(1, N-1):
    if H[i] > H[i-1]:
        H[i] -= 1
    if H[i] > H[i+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):
import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
if np.any(np.diff(H) >= 2):
  print("No")

print("Yes")


import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))
if all(np.diff(H) >= 0):
  print("Yes")

for i in range(N):
  h = H.copy()
  h[i] = h[i] - 1
  if all(np.diff(h) >= 0):
    print("Yes")

print("No")


import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
diffH = np.diff(H)
if np.any((diffH[range(N-1)] + diffH[range(1, N)]) <= -2):
  print("No")
 
print("Yes")

import numpy as np
N = int(input())
H = list(map(int, input().split()))

max = 0
for i in range(N):
  if max < H[i]:
    max = H[i]
  if max - H[i] >= 2:
    print("No")
    exit(0)
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())
n = len(list(str(N)))
cnt = 0
if n==1:
    print(N)
else:
    for i in range(n//2):
        cnt += 9 * (10 ** (2 * i))  
    if n%2==1:
        cnt += N - (10 ** (2 ** (n-2))) + 1
    print(cnt)

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

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

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

flag = 0

if len(lst) == 1:
    flag = 1

if flag == 0:
    for i in range(1, len(lst)):
        if lst[i-1]+1 == lst[i]:
            lst[i-1] = lst[i-1] - 1

if flag == 0:
    for i in range(1, len(lst)):
        if (lst[i-1] <= lst[i]) & (flag == 0):
            # print(str(lst[i])+'<='+str(lst[i+1]))
            flag = 0
        else:
            flag = 1

if flag == 0:
    print('Yes')
else:
    if len(lst) == 1:
        print('Yes')
    else:
        print('No')


n = int(input())
lst = [int(i) for i in input().split()]

flag = 0

for i in range(0,len(lst)-1):
    if lst[i]-1 == lst[i+1]:
        lst[i] = lst[i] - 1
        print(lst)


if flag == 0:
    for i in range(0,len(lst)-1):
        if (lst[i] <= lst[i+1])&(flag==0):
            print(str(lst[i])+'<='+str(lst[i+1]))
            flag = 0
        else:
            flag = 1


print(lst)
if flag == 0:
    print('Yes')
else:
    print('No')

N = int(input())
lst = sorted(map(int, input().split()))

print(lst)
flag = 0
for i in range(0,len(lst)-1):
    print(i)
    if lst[i]-1 == lst[i+1]:
        lst[i] = lst[i] - 1


print(lst)

if flag == 0:
    for i in range(0,len(lst)-1):
        if lst[i] <= lst[i+1]:
            flag = 0
        else:
            flag = 1



if flag == 0:
    print('Yes')
else:
    print('No')

n = int(input())
lst = [int(i) for i in input().split()]

for i in range(len(lst)-1):
    if lst[i] == lst[i+1]+1:
        lst[i] -= 1

flag = 0
for i in range(len(lst)-1):
    if (lst[i] <= lst[i + 1]) & (flag==0):
        flag = 0
    else:
        flag = 1

if len(lst) == 1:
    flag = 1
print(lst)

if flag == 0:
    print('Yes')
else:
    if len(lst) == 1:
        print('Yes')
    else:
        print('No')

n = int(input())
lst = [int(i) for i in input().split()]

lst[0] -=1
for i in range(1,len(lst)):
    if (lst[i-1] != lst[i]) or (lst[i-1] > lst[i]):
        lst[i] -= 1

flag = 0
for i in range(len(lst)-1):
    if (lst[i] <= lst[i + 1]) & (flag==0):
        flag = 0
    else:
        flag = 1

if len(lst) == 1:
    flag = 1


if flag == 0:
    print('Yes')
else:
    if len(lst) == 1:
        print('Yes')
    else:
        print('No')


Verdicts: 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):
N = int(input())
H = list(map(int,input().split()))
flg = 0
ans = "Yes"

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

for j in range(N-1):
  if H[j] > H[j+1]:
    ans = "No"

print(ans)

N = int(input())
H = list(map(int,input().split()))
flg = 0
ans = "Yes"

for i in range(N-1):
  if H[i]-H[i+1] > 1:
    ans = "No"
    break
  elif H[i]-H[i+1] == 1 and flg == 0:
    flg = 1
  elif H[i]-H[i+1] == 1 and flg == 1:
    ans = "No"
    break
  elif H[i]-H[i+1] == 0:
    continue
  else:
    flg = 0
    continue

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()))
p = 0
flag = 0
for i in range(1, len(h) - 1):
  
  if (h[i - 1] - h[i]) > 1:
    print('No')
    exit()
  elif (h[i - 1] - h[i]) == 1:
    if flag == 1:
      print('No')
      exit()
    else:
      flag == 1
  elif (h[i - 1] - h[i]) == 0:
    flag == 1
  
  elif (h[i + 1] - h[i]) < 0:
    if flag == 1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) < -1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) == -1:
      if flag == 1:
        print('No')
        exit()
      else:
        flag = 1
  elif (h[i + 1] - h[i]) >= 0 and flag == 1:
    flag == 0
print('Yes')

n = int(input())
h = list(map(int, input().split()))
p = 0
flag = 0an = int(input())
h = list(map(int, input().split()))
p = 0
flag = 0
for i in range(1, len(h) - 1):
  
  if (h[i - 1] - h[i]) > 1:
    print('No')
    exit()
  elif (h[i - 1] - h[i]) == 1:
    if flag == 1:
      print('No')
      exit()
    else:
      flag == 1
  elif (h[i - 1] - h[i]) == 0:
    flag == 1
  
  elif (h[i + 1] - h[i]) < 0:
    if flag == 1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) < -1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) == -1:
      if flag == 1:
        print('No')
        exit()
      else:
        flag = 1
  elif (h[i + 1] - h[i]) >= 0 and flag == 1:
    flag == 0
print('Yes')
for i in range(1, len(h) - 1):
  
  if (h[i - 1] - h[i]) > 1:
    print('No')
    exit()
  elif (h[i - 1] - h[i]) == 1:
    if flag == 1:
      print('No')
      exit()
    else:
      flag == 1
  elif (h[i - 1] - h[i]) == 0:
    flag == 1
  
  elif (h[i + 1] - h[i]) < 0:
    if flag == 1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) < -1:
      print('No')
      exit()
print('Yes')

n = int(input())
h = list(map(int, input().split()))
p = 0
flag = 0
for i in range(1, len(h) - 1):
  
  if (h[i - 1] - h[i]) > 1:
    print('No')
    exit()
  elif (h[i - 1] - h[i]) == 1:
    if flag == 1:
      print('No')
      exit()
    else:
      flag == 1
  elif (h[i - 1] - h[i]) == 0:
    if flag == 1:
      print('No')
      exit()
    else:
      flag == 1
  
  if (h[i + 1] - h[i]) < 0:
    if flag == 1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) < -1:
      print('No')
      exit()
    elif (h[i + 1] - h[i]) == -1 and flag == 0:
      flag = 1
      h[i] -= 1
  elif (h[i + 1] - h[i]) >= 0:
    flag == 0
print('Yes')

n = int(input())
h = list(map(int, input().split()))
p = h[-1]
flag = 0
for i in h[::-1]:
  if i <= p:
    p = i
    continue
  elif (i - p) == 1:
    p = i - 1
  else:
    print('No')
    exit()
print('Yes')

Verdicts: Wrong Answer

Runtime Error

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

n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  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())
a=list(int(input())for i in range(n))
b=0
for i in range(n):
  if a[i]-a[i+1]>=2:
    b+=1
if b==0:
  print("Yes")
else:
  print("No")


n=int(input())
a=list(for i in range(n))
b=0
for i in range(n):
  if a[i]-a[i+1]>=2:
    b+=1
if b==0:
  print("Yes")
else:
  print("No")

n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
c=b[0]
d=b[n-1]
if d-c==0or1
  print("Yes")
else:
  print("No")



n=int(input())
a=list(int,input().split())
b=0
for i in range(n):
  if a[i]-a[i+1]>=2:
    b+=1
if b==0:
  print("Yes")
else:
  print("No")


n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
c=b[0]
d=b[n-1]
if d-c==0or1
  print("Yes")
else:
  print("No")



n=int(input())
a=list(map(int,input().split()))
b=0
c=a.reverse()
d=0
for i in range(n-1):
  if a[i]-a[i+1]==1:
    a[i+1]=a[i+1]-1
  elif a[i]-a[i+1]>=2:
    b+=1
  else:
    d=d
    
if b==0:
  print("Yes")
else:
  print("No")

n=int(input())
a=list(map(int,input().split()))
b=0
c=a.reverse()
d=0
for i in range(n-1):
  if a[i]-a[i+1]==-1:
    a[i+1]=a[i+1]-1
  elif a[i]-a[i+1]<=-2:
    b+=1
  else:
    d=d
    
if b==0:
  print("Yes")
else:
  print("No")


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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()))
err=0
for i in range(n-1):
    if(h[i]>min(h[i+1:n])):
        h[i]=h[i]-1
    if(i>=1):
        if(h[i-1]>h[i]):
            err=1
if(h[n-2]>h[n-1]):
    err=1
if(err==1):
    print('No')
else:
    print('Yes')
print(h)

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

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

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())
l=list(map(int,input().split()))
b=True
for i in range(1,n):
  if l[-i]>=l[-i-1]:
    pass
  elif l[-i]=l[-1-i]+1:
    l[-1-i]=l[-1-i]-1
  else:
    b=False
    break
if b:
  print("Yes")
else:
  print("No")

n=int(input())
l=list(map(int,input().split()))
b=True
for i in range(1,n):
  if l[-i]>=l[-i-1]:
    pass
  elif l[-i]==l[-1-i]+1:
    l[-1-i]=l[-1-i]-1
  else:
    b=False
    break
if b:
  print("Yes")
else:
  print("No")


n=int(input())
l=list(map(int,input().split()))
b=True
for i in range(1,n):
  if l[n-i]>=l[n-i-1]:
    pass
  elif l[n-i]==l[n-1-i]-1:
    p=l[n-1-i]
    l[n-1-i]=p-1
  else:
    b=False
    break
if b:
  print("Yes")
else:
  print("No")


Verdicts: Runtime Error

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()))
flag = True
reach = False

for n in range(N - 1):
  if H[n] > H[n + 1]:
    if H[n] - 1== H[n + 1] and H[n + 1] + 1 <= H[n + 2] and reach == False:
      reach = True
    else:
      flag = False
if flag:
  print("Yes")
else:
  print("No")

N = int(input())
H = list(map(int, input().split()))
flag = True
maxim = 0

for n in range(N):
  if maxim < H[n]:
    maxim = H[n]
  if H[n] < maxim -1:
      flag = False
if flag:
  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 = [int(i) for i in input().split()]
i = n - 1
while i >= 1:
    print(i)
    if h[i] >= h[i-1]:
        i -= 1
    elif h[i] == h[i-1] - 1:
        h[i-1] -= 1
        i -= 1
    else:
        print('No')
        break
else:
    print('Yes')

n = int(input())
h = [int(i) for i in input().split()]
i = n - 1
while i >= 1:
    if h[i] >= h[i-1]:
        i -= 1
    elif h[i] == h[i-1] - 1:
        h[i-1] -= 1
        i -= 1
    else:
        print('No')
        break
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):
n = int(input())
h = list(map(int, input().split()))

ht = h[0]
ans="Yes"
for i in h:
  if 0 <= i - ht <= 1:
    ht = i
  elif i - ht == 2:
    ht = i-1
  else:
    ans="No"
    break
    
print(ans)

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

ht=h[-1]
ans="Yes"
for i in reversed(h):
  if 0 <= i <= ht+1:
    if ht+1 == i:
      ht = i-1
    else:
      ht = i
  else:
    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(sys.stdin.readline().rstrip())
H = list(map(int, sys.stdin.readline().rstrip().split()))
print(H)
result = True
for k in range(N-1):
    if H[k]-1 > min(H[k+1:]):
        print("No");exit()
print("Yes")

import sys
N = int(sys.stdin.readline().rstrip())
H = list(map(int, sys.stdin.readline().rstrip().split()))
for k in range(2,N+1):
    if H[-k] <= H[-k+1]:
        continue
    elif H[-k] == H[-k+1] + 1:
    	H[-k] -= 1
    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=list(map(int,input().split()))
print(N,H)

H.insert(N,10**9)

ans='Yes'

for i in range(N):
    if H[i]<H[i+1]:
        H[i+1]=H[i+1]-1

    elif H[i]>H[i+1]:
        ans='No'
        break

print(ans)




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


H.insert(N,10**9)

ans='Yes'

for i in range(N):
    if H[i]<H[i+1]:
        H[i+1]=H[i+1]-1

    elif H[i]>H[i+1]:
        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):
n = int(input())
list_h = list(map(int, input().split()))


for i in reversed(range(1, n)):
    print(list_h, i)
    l, r = list_h[i-1], list_h[i]

    
    if l <= r:
        continue

    
    elif l - 1 == r:
        list_h[i-1] = list_h[i-1] -1
        continue
    
    else:
        print("No")
        exit()

print("YES")

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


for i in reversed(range(1, n)):
    l, r = list_h[i-1], list_h[i]

    
    if l <= r:
        continue

    
    elif l - 1 == r:
        list_h[i-1] = list_h[i-1] -1
        continue
    
    
    else:
        print("NO")
        exit()

print("YES")

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


for i in reversed(range(1, n)):
    l, r = list_h[i-1], list_h[i]

    
    if l <= r:
        continue

    
    elif l - 1 == r:
        list_h[i-1] = list_h[i-1] -1
        continue
    
    else:
        print("No")
        exit()

print("YES")


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


for i in range(n-1):
    l, r = list_h[i], list_h[i+1]
    if l == R:
        continue
    elif l + 1 == r:
        list_h[i+1] = list_h[i+1] -1
        continue
    else:
        print("No")
        exit()

print("YES")

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


for i in reversed(range(1, n)):
    l, r = list_h[i-1], list_h[i]

    
    if l <= r:
        continue

    
    elif l - 1 == r:
        list_h[i-1] = list_h[i-1] -1
        continue

    
    else:
        print("No")
        exit()

print("Yes")

Verdicts: Runtime Error

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):
import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
h = na()
hpre = h[-1]
print(h[:-1][::-1])
for hi in h[:-1][::-1]:
    if hi <= hpre:
        hpre = hi
    elif hi == hpre + 1:
        hpre = hi - 1
    else:
        print("No")
        quit()
print("Yes")

import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
h = na()
hpre = h[-1]
for hi in h[:-1][::-1]:
    if hi <= hpre:
        hpre = hi
    elif hi == hpre + 1:
        hpre = hi - 1
    else:
        print("No")
        quit()
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):
import sys
N = int(input())
H = [int(h) for h in input().split(" ")]

h_previous = -10
for i, h in enumerate(H):
  
  if h_previous <= H[i]-1:#
    H[i] -= 1
    h_previous = H[i]
  else:
    print("No")
    sys.exit()
    
  print("Yes")
  

import sys
N = int(input())
H = [int(h) for h in input().split(" ")]

h_previous = -10
for i, h in enumerate(H):
  
  if h_previous <= H[i]:
    h_previous = H[i]
  elif h_previous <=H[i] -1:
    h_previous = H[i] -1
  else:
    print("No")
    sys.exit()
    
  print("Yes")
  


import sys
N = int(input())
H = [int(h) for h in input().split(" ")]

h_previous = -10
for i, h in enumerate(H):
  
  if h_previous <= H[i] - 1:
    h_previous = H[i] - 1 
  elif h_previous <= H[i]:
    h_previous = H[i]
  else:
    print("No") 
    sys.exit()
    
  print("Yes")
  


import sys
N = int(input())
H = [int(h) for h in input().split(" ")]

flag = True
h_previous = -10
for i, h in enumerate(H):
  
  if h_previous <= H[i] - 1:
    h_previous = H[i] - 1 
  elif h_previous <= H[i]:
    h_previous = H[i]
  else:
    flag = False
    break
    
  
if flag:
  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()))
# F = [0]*len(H)
ans = 'Yes'
flag = False
for i in range(len(H)-1):
    if H[i] - H[i+1] > 1:
        ans = 'No'
        break
    elif H[i] - H[i+1] > 0:
        flag = True
        if flag:
            ans  = 'No'
    elif H[i] - H[i+1] < 0:
            flag = False
            # if H[i] - H[i+1] > 1:
    #     ans = 'No'
    #     break
    # elif H[i] - H[i+1] == 1:
    #     if flag:
    #         ans = 'No'
    
    # else:
    

print(ans)


N = int(input())
H = list(map(int,input().split()))
# F = [0]*len(H)
ans = 'Yes'
flag = False
for i in range(len(H)-1):
    if H[i] - H[i+1] > 1:
        ans = 'No'
        break
    elif H[i] - H[i+1] > 0:
        if flag:
            ans  = 'No'
        flag = True

    elif H[i] - H[i+1] < 0:
            flag = False

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())
L=list(map(int,input().split()))
M=[0]*N
count=0
while(1):
	for i in range (N-1):
		if L[i]>L[i+1]:
			if M[i]==1:
				print("No")
				exit()
			else:
				L[i]-=1
				M[i]=1
		else:
			count+=1
	if count==(N-1):
		print("Yes")
		exit()


N=int(input())
L=list(map(int,input().split()))
M=[0]*N
count=0
while(1):
	count=0
	for i in range (N-1):
		if L[i]>L[i+1]:
			if M[i]==1:
				print("No")
				exit()
			else:
				L[i]-=1
				M[i]=1
		else:
			count+=1
	if count==(N-1):
		print("Yes")
		exit()


Verdicts: Time Limit Exceeded

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, N):
    if H[i] >= H[i-1] - 1:
        H[i-1] -= 1
    elif H[i] < H[i-1] - 1:
        print("No")
        sys.exit()

if flag == 0:
    print("Yes")

import sys

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

for i in range(1, N):
    if H[i] + 1 == H[i-1]:
        H[i] += 1
    elif H[i] + 1 < H[i-1]:
        print("No")
        sys.exit()
        
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())
h = list(map(int, input().split()))

i = 0
while True:
    if i == n-1:
        print('Yes')
        break
    if h[i] <= h[i+1]:
        print(i, 'a', h)
        if i == 0 or h[i-1] < h[i]:
            h[i] -= 1
        i += 1
    elif h[i] == h[i+1]+1 and (i==0 or h[i-1] < h[i]):
        print(i, 'b', h)
        h[i] -= 1
        i += 1
    else:
        print('No')
        break

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

i = 0

while True:
    if i == n-1:
        print('Yes')
        break
    if h[i] <= h[i+1]:
        if i == 0 or h[i-1] < h[i]:
            h[i] -= 1
        i += 1
    elif h[i] == h[i+1]+1 and (i==0 or h[i-1] < h[i]):
        h[i] -= 1
        i += 1
    else:
        print('No')
        break

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 = False
for i in range(1, N):
    if H[i-1] > H[i]:
        if H[i-1] == H[i]+1:
            if flag:
                break
            else:
                H[i-1] -= 1
                flag = True 
        else:
            break
    else:
        if flag==False:
            H[i-1] -= 1
        flag = False

if H == sorted(H):
    print('Yes')
else:
    print('No')

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

flag = False
for i in range(1, N):
    if H[i-1] > H[i]:
        if H[i-1] == H[i]+1:
            if flag==False:
                H[i-1] -= 1
                flag = True
        else:
            break
        if flag==False:
            H[i-1] -= 1
    else:
        if flag==False:
            H[i-1] -= 1
        if H[i-1] != H[i]:
            flag = False
print(H)
if H == sorted(H):
    print('Yes')
else:
    print('No')

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

for i in range(N-1):
    if i==0:
        is_equal_to_left = False
    else:
        is_equal_to_left = H[i-1] == H[i]
    
    if is_equal_to_left:
        pass
    else:
        H[i] -= 1

        
H_sorted = sorted(H)

if H == H_sorted:
    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):
import sys
n = int(input())
h = list(map(int,input().split()))
for k in range(n-1):
    if h[k+1]==h[k]-1:
        h[k+1]=h[k]+1
    elif h[k+1]>h[k]:
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

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

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

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

Verdicts: 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())
l=list(map(int, input().split()))
flg=0
for i in range(n-1):
  if (l[i] - l[i+1]) < -1 or (l[i] - l[i+1] == -1 and l[i] <= flg):
    print('No')
    exit()
print('Yes')

n=int(input())
l=list(map(int, input().split()))
l[0] -= 1
ans="Yes"
for i in range(1, n):
  if l[i] > l[i-1]:
    l[i] -= 1
  if l[i] < l[i-1]:
    print("No")
    exit()
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())
boxes = input().split(" ")
for i in range(N):
    boxes[i] = int(boxes[i])

if N == 1:
    print("Yes")
    sys.exit()

ok = True
for i in range(0, N-1):
    diff = boxes[i+1] - boxes[i]
    if diff >= 0:
        continue
    elif diff == -1:
        boxes[i] -= 1
        if i > 1 and boxes[i] - boxes[i-1] <= -1:
        	ok = False
        	break
        print(i, boxes[i])
    elif diff >= -2:
        ok = False
        break

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


N = int(input())
boxes = input().split(" ")
for i in range(N):
    boxes[i] = int(boxes[i])

ok = True
max_value = 1
for i in range(N-1):
    if max_value < boxes[i]:
        max_value = boxes[i]

    diff = boxes[i+1] - boxes[i]
    if diff >= 0:
        pass
    elif diff == -1:
        boxes[i] -= 1
        if max_value - 1 > boxes[i]:
            ok = False
    else:
        ok = False

    if not ok:
        break

if ok:
    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 = [int(x) for x in input().split(' ')]
m = max(h)

for i in range(0, n):
    if m - h[i] > 1:
        print('No')
        exit()
print('Yes')

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

N = int(input())
H = list(map(int,input().split()))
H.reverse()
cnt = 0
for i in range(N-1):
  if H[i+1]-H[i]==1:
    H[i+1] = H[i+1]-1
  elif H[i+1]-H[i]>1:
    cnt = 1
    break
if cnt == 0:
  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()))
count=0
for i in range(N-1):
    if (H[i+1]-H[i])>1:
        if max(H)!=H[N-1]:
            count=1
print("YES" if count==0 else "NO")

N=int(input())
H=list(map(int,input().split()))
pre=0
for h in H:
    if h<pre:
        print("No");exit()
    elif h>pre:
        pre=h-1
print("Yes")

Verdicts: Wrong Answer

Accepted