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):
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()
a = inlist()
res = "Yes"
for i in range(N-1):
    if a[i] >= a[i+1]:
        a[i] -= 1
for i in range(N-1):
    if a[i+1] < a[i]:
        res = "No"
        break

print(res)


# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()
a = inlist()
res = "Yes"
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+1] < a[i]:
        res = "No"
        break
print(res)


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

for i in range(1,n)[::-1]:
    if l[i-1] - 1 == l[i]:
        l[i] = l[i] + 1
    else:
        continue
    
#print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


n = int(input())
l = [int(x) for x in input().split()]
#print(l)

for i in range(1,n)[::-1]:
    if l[i-1] - 1 == l[i]:
        l[i] = l[i] + 1
    else:
        continue
    
print(l)

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')




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

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

a = 0
for j in range(1, n):
    if l[j-1] <= l[j]:
        continue
    else:
        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):
import sys

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

n_str = str(n)
li_size = len(li)

for i in range(li_size):
  li_contents = li[i] - 1
  for j in range(li_size - i):
    if li_contents > li[j + i]:
      print("NO")
      sys.exit()
print("YES")

import sys

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

n_str = str(n)
li_size = len(li)
max = li[0]
for i in range(li_size):
  if max == li[i]:
    continue
  elif max > li[i]:
    print("No")
    sys.exit()
  elif max < li[i]:
    max = li[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 = list(map(int, input().split()))
for i in range(n-1):
  if h[i]+2 <= h[i+1]:
    print("No")
    break
else:
  print("Yes")

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

before = h[0]
for i in range(1,n):
  if before > h[i]:
    print("No")
    break
  before = max(h[i]-1, before)
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()))
max=max(h)
res='Yes'
for val in h:
    if val < max -1:
        res = 'No'
print(res)

n=int(input())
h=list(map(int,input().split()))
max=0
res='Yes'
for i in range(n):
    if i == n -1:
        break
    if max < h[i]:
        max=h[i]
    diff = h[i] - h[i+1]
    if  diff > 1 or (max - h[i+1]) > 0:
        res='No'
        break
    elif diff == 1:
        max -= 1
    else:
        pass

print(res)

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

h_new = []
h_new.append(h[0]-1)

for i in range(1, n-1):
    if h[i+1] < h[i]:
        h_new.append(h[i]-1)
    else:
        h_new.append(h[i])
h_new.append(h[-1])

print(h_new)
cnt = 0
for i in range(n-1):
    if h_new[i] > h_new[i+1]:
        print('No')
        exit()
    else:
        cnt += 1

if cnt == len(h_new)-1:
    print('Yes')

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

h_new = []

for i in range(n-1):
    if h[i] - h[i+1] >=1:
        h_new.append(h[i]-1)
    else:
        h_new.append(h[i])
h_new.append(h[-1])

cnt = 0
for i in range(n-1):
    if h_new[i] < h_new[i+1]:
        print('No')
        exit()
    else:
        cnt += 1

if cnt == len(h_new)-1:
    print('Yes')

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

h_new = []

for i in range(n-1):
    if h[i] - h[i+1] >=1:
        h_new.append(h[i]-1)
    else:
        h_new.append(h[i])
h_new.append(h[-1])

cnt = 0
for i in range(n-1):
    if h_new[i] <= h_new[i+1]:
        print('No')
        exit()
    else:
        cnt += 1

if cnt == len(h_new)-1:
    print('Yes')

n = int(input())
h = list( map(int,input().split()) )
 
ck = True
for i in range(n-2,-1,-1):
  if h[i] > h[i+1]:
    h[i] -= 1
    if h[i] > h[i+1]:
        ck = False
        break

print('Yes' if ck else '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):
import numpy as np
N=int(input())
H=list(map(int,input().split()))

L=H
#print(H)
le=int(len(H))
#maxh=max(H)
#print(maxh)
maxi=np.argmax(H)
txt="Yes"

#     if H[i]<=H[maxi]-1:
#         txt="No"
#         break
# print(txt)

for j in range(0,le-2):
    if maxi==le-1:
        pass
    else:
        for i in range(maxi+1,le-1):
            if H[i]<=H[maxi]-1:
                txt="No"
                flag=1
                break
        if flag==1:
            break
    L[maxi]=0
    maxi=np.argmax(L)
print(txt)


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

L=H
#print(H)
le=int(len(H))
#maxh=max(H)
#print(maxh)
maxi=np.argmax(H)
txt="Yes"

#     if H[i]<=H[maxi]-1:
#         txt="No"
#         break
# print(txt)

for j in range(0,le-2):
    if maxi==le-1:
        pass
    else:
        for i in range(maxi+1,le-1):
            if H[i]<=H[maxi]-1:
                txt="No"
                break
    L[maxi]=0
    maxi=np.argmax(L)
print(txt)


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

L=H
#print(H)
le=int(len(H))
#maxh=max(H)
#print(maxh)
maxi=np.argmax(H)
txt="Yes"

L[maxi]=0
maxi=np.argmax(L)
a=0
for i in range(0,N):
    if a-1>H[i]:
        txt="No"
        break
    if H[i]>a:
        a=H[i]


# for j in range(0,le-2):
#     if maxi==le-1:

#     else:

#             if H[i]<=H[maxi]-1:
#                 txt="No"
#                 flag=1
#                 break
#         if flag==1:
#             break
#     L[maxi]=0
#     maxi=np.argmax(L)
print(txt)


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

le=int(len(H))

a=0
for i in range(0,N):
    if a-1>H[i]:
        print("No")
        sys.exit()
    if H[i]>a:
        a=H[i]
print("Yes")


Verdicts: 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()))
# A = []
# for a in range(N+1):
#     A.append(int(input()))

H[0] -= 1

for i in range(1, N):

    if H[i-1] > H[i]:
        print('NO')
        exit()

    H[i] = max(H[i-1], H[i] - 1)

print('YES')


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

H[0] -= 1

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

    H[i] = max(H[i-1], H[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):
import sys

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

while True:
    a = L.pop(0)
    if len(L) <= 0:
        break

    if L[0] - a > 1:
        print("No")
        sys.exit()

print("Yes")


import sys

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

n = L[0]
while True:
    if len(L) <= 0:
        break

    if L[0] - n < -1:
        print("No")
        sys.exit()

    n = max(n, L[0])
    L.pop(0)

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 = [int(i) for i in list(input())]
ans = True
a[0] -= 1
for i in range(1,n):
  if a[i]>a[i-1]:
    a[i] -= 1
  elif a[i]==a[i-1]:
    pass
  else:
    ans = False
    break
if ans==True:
  print("Yes")
else:
  print("No")

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

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

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1

if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

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

i = 0
flag = 0
for i in range(1,n-1):
    print(h)
    if(h[i] > h[i+1]+2):
        break
        flag = 1
    elif(h[i] >= h[i+1]+1):
        if(h[i-1] == h[i]):
            break
            flag = 1
        else:
            h[i] -= 1
    elif(h[i-1] != h[i]):
        h[i] -= 1

if(h[n-2] > h[n-1]):
    flag = 1    



if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

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

i = 0
flag = 0

if(n > 2):
    for i in range(1,n-1):
        #print(h)
        if(h[i] > h[i+1] + 1):
            flag = 1
            break
        elif(h[i] == h[i+1]+1):
            if(h[i-1] == h[i]):
                flag = 1
                break
            else:
                h[i] -= 1
        elif(h[i-1] != h[i]):
            h[i] -= 1
    
    if(h[-2] > h[-1]):
        flag = 1   
elif(n == 2):
    if(h[0]-1 > h[1]):
        flag = 1


if(flag == 0 or n == 1):
    print("Yes")
else:
    print("No")

Verdicts: 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):
ccc=[list(map(int,input().split())) for i in range(2)]

for idx in range(2,n):
  if (ccc[1][idx-1] == ccc[1][idx]):
    continue
  elif (ccc[1][idx-1] - 1 == ccc[1][idx] ):
    ccc[1][idx] = ccc[1][idx-1]
    continue
  elif (ccc[1][idx-1] -1 > ccc[1][idx] ):
    print("No")
    break
    
  if (idx == n-1):
    print("Yes")
  


ccc=[list(map(int,input().split())) for i in range(2)]


if ccc[0][0] == 1:
  print("Yes")
else:
  for idx in range(1,ccc[0][0]):
    if (ccc[1][idx-1] <= ccc[1][idx]):
      if (idx == ccc[0][0]-1):
        print("Yes")
      continue
    elif (ccc[1][idx-1]  == ccc[1][idx] + 1 ):
      ccc[1][idx] = ccc[1][idx-1]
      if (idx == ccc[0][0]-1):
        print("Yes")
      continue
    elif (ccc[1][idx-1] -1 > ccc[1][idx] ):
      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):
import sys
n=int(input())
h=list(map(int,input().split()))
if h[0]>0:
  h[0]-=1
for i in range(1,n):
  if h[i-1]==h[i]:
    sonomama=1
  elif h[i]>[i-1]:
    h[i]-=1
  else:
    print("No")
	sys.exit()
print("Yes")
    

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

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

li.reverse()

mins = 100000000000

isyes = True
for i in li:
    if i < mins:
        mins = i
    
    if i - mins > 1:
        isyes=False

if(isyes):
    print('YES')
else:
    print('NO')


a=int(input())

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

li.reverse()

mins = 100000000000

isyes = True
for i in li:
    if i < mins:
        mins = i
    
    if i - mins > 1:
        isyes=False

if(isyes):
    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):

import sys
N = int(sys.stdin.readline().strip());
H = sys.stdin.readline().split();
H = [int(x) for x in H]

q = [0 for x in range(N)]

u = H[::-1]
q[0] = u[0]


flag = True

for i in range(1, N):
	
	if(u[i]>=q[i-1]):
		flag = False
		break
	
	if(u[i]==q[i-1]+1):
		
		q[i] = u[i]-1
	else:
		
		q[i] = u[i]

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



import sys
N = int(sys.stdin.readline().strip());
H = sys.stdin.readline().split();
H = [int(x) for x in H]

q = [0 for x in range(N)]

u = H[::-1]
q[0] = u[0]


flag = True

for i in range(1, N):
	
	if(u[i]>=q[i-1]+2):
		flag = False
		break
	
	if(u[i]==q[i-1]+1):
		
		q[i] = u[i]-1
	else:
		
		q[i] = u[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 = map(int,input().split())

for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    H(N-i-2) -= 1
    
f = 0
for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    f = 1
    
if f == 0:
  print("No")
else:
  print("Yes")

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

for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    H(N-i-2) -= 1
    
f = 0
for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    f = 1
    
if f = 0:
  print("No")
else:
  print("Yes")

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

for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    H[N-i-2] -= 1
    
f = 0
for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    f = 1
    
if f == 0:
  print("No")
else:
  print("Yes")

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

for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    H[N-i-2] -= 1
    
f = 0
for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    f = 1
    
if f == 0:
  print("Yes")
else:
  print("No")

Verdicts: 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()))
if N>1:
    for i in range(N-1,0,-1):
        if H[i] < H[i-1] :
            H[i-1] -= 1
if sorted(H) != H:
    print('NO')
else:
    print('YES')

N = int(input())
H = list(map(int,input().split()))
flag = 0
if (N==1 ) or (N==2 and H[1]<=H[2]+1):
    flag = 1
elif (N == 2 and H[1]> H[2]+1):
    flag = 0
else:
    for i in range(N-2):
        if H[i] - H[i+2] <=2 or  H[i] - H[i+1] <=2:
            flag = 1
        else:
            flag = 0
if flag ==1:
    print('YES')
else:
    print('NO')


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

N=int(input())
H=map(int, input().split())
for i in range(N-1):
    A=H[i+1]
    B=H[i]-1
    if A < B:
        print('No')
    else:
        print('Yes')

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

N=int(input())
H=list(map(int, input().split()))
count=0
for i in range(N-1):
    A=H[i+1]
    B=H[i]-1
    if A < B:
        print('No')
        Z=Z+1
        break
    if A == B:
        count=count+1
        if count == 2:
            print('No')
            Z=Z+1
            break
if Z == 0:
    print('Yes')

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

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

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

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

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

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

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

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

N=int(input())
H=list(map(int, input().split()))
Z=0
count=0
for i in range(N-1):
    A=H[i+1]
    B=H[i]-1
    if A < B:
        print('No')
        Z=Z+1
        break
    if A == B:
        count=count+1
        if count >=2 and A < C:
            print('No')
            Z=Z+1
            break
        else:
            C=A
if Z == 0:
    print('Yes')

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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())
heights = [int(i) for i in input().split()]
ans = "Yes"
for i in range(N):
    if 0 < i and 1 < heights[i]-heights[i-1]:
        ans = "No"
        break
print(ans)

N = int(input())
heights = [int(i) for i in input().split()]
ans = "Yes"
minv = heights[0]
for i in range(N):
    if 1 < minv - heights[i]:
        ans = "No"
        break
    minv = max(minv,heights[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()))

for i in range(1, n):
  if h[i-1] == h[i]:
    continue
  elif h[i-1] == h[i] - 1:
    continue
  else:
    print('No')
    exit()

print('Yes')

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

for i in range(1, n):
  if h[i-1] == h[i]:
    continue
  elif h[i-1] == h[i] - 1:
    continue
  else:
    print('No')
    print(i)
    exit()

print('Yes')

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

for i in range(n-2, 0, -1):
  if h[i] > h[i+1]:
    h[i] -= 1
    
  if h[i] > h[i+1]:
    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()))

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

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

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

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

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

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 H[i] >= H[i+1]:
        H[i] -= 1

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

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

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

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

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

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

for i in range(N - 2):
    if (H[i] >= H[i + 1] and H[i + 1] > H[i + 2]) or (H[i] > H[i + 1] and H[i + 1] >= H[i + 2]) or H[i]-H[i+1]>1:
        ok = False
if  N >= 2 and H[-2] - H[-1] > 1:
    ok = False

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


N = int(input())
H = list(map(int, input().split()))
ok = False
r = H[-1]
if N == 1:
    ok = True
else:
    H.pop(-1)
    l = max(H)
if ok or l - r <= 1:
    print("YES")
else:
    print("NO")


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

for i in range(1,N):
    if H[i-1] > H[i]:
        print("No")
        exit()

    if H[i-1] < H[i]:
        H[i] -= 1

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()))
c = 0
for i in range(N-1):
  if H[i] > H[i+1]:
    H[i+1] = H[i+1] + 1
  if H[i] <= H[i+1]:
    C += 1
if C == N-1:
  print('Yes')
else:
  print('No')


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

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

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

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

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

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

import sys

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

cnt = 0
for i in range(N - 1):
    if H[i] < H[i + 1]:
        cnt = 0
        continue
    elif H[i] == H[i + 1]:
        continue
    else:
        if H[i] - 1 <= H[i + 1]:
            H[i] -= 1
            cnt += 1
            if cnt >= 2:
                print("No")
                sys.exit()
        else:
            print("No")
            sys.exit()
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())
L=list(int(input()) for _ in range(N))
M=L[::-1]
for i in range(N-1):
    if M[i]+1<M[i+1]:
        print('No')
        break
    elif M[i]+1=M[i+1]:
        M[i+1]=M[i]
else:print('Yes')

N=int(input())
L=list(int(input()) for _ in range(N))
M=L[::-1]
for i in range(N-1):
    if M[i]+1<M[i+1]:
        print('No')
        break
    elif M[i]+1==M[i+1]:
        M[i+1]=M[i]
else:print('Yes')

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

Verdicts: 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())
H = list(map(int, input().split()))
flag = True
for i in range(n - 1):
    if H[i] - H[i + 1] > 1:
        flag = False
    elif H[i] == H[i + 1]:
        continue
    elif H[i] - H[i + 1] == 1:
        H[i + 1] += 1

print(flag)

n = int(input())
H = list(map(int, input().split()))
flag = True
H[0] -= 1
for i in range(1, n):
    if H[i] - H[i - 1] > 0:
        H[i] -= 1
    elif H[i] - H[i - 1] < 0:
        flag = False

print('Yes' if flag == True 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):
def debug(*args):
    if 1 == 1:
        print(*args)

def solve(N, A):
    for i in range(1, N):
        if A[i-1] > A[i] + 1:
            return "No"
        elif A[i-1] + 1 == A[i]: #
            A[i] -= 1
        elif A[i-1] == A[i]: 
            pass
        elif A[i-1] + 1 < A[i]:
            A[i] -= 1
        elif A[i-1] <= A[i]:
            continue
        return "No"
    return "Yes"

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    print(solve(N, A))

main()






def debug(*args):
    if 1 == 1:
        print(*args)

def solve(N, A):
    A[0] -= 1
    for i in range(1, N):
        if A[i-1] <= A[i] - 1: 
            A[i] -= 1
        if A[i-1] > A[i]:
            return "No"
    return "Yes"

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    print(solve(N, A))

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())
list_h= list(map(int,input().split()))
check = 0
for i in range(n-1):
    if list_h[i+1] >= list_h[i]:
        list_h[i] -= 1
        check = 0
    elif list_h[i+1] < list_h[i] - 1:
        check = 2
        break
    elif list_h[i+1] == list_h[i] - 1:
        list_h[i] -= 1
        check += 1
if check <= 1 or n == 1:
    print("Yes")
else:
    print("No")
print(check)

n = int(input())
list_h= list(map(int,input().split()))
check = 0
for i in range(n-1):
    if list_h[i+1] > list_h[i]:
        check = 0
    elif list_h[i+1] == list_h[i] and check == 0:
        list_h[i] -= 1
    elif list_h[i+1] < list_h[i] - 1:
        check = 2
    elif list_h[i+1] == list_h[i] - 1:
        list_h[i] -= 1
        check += 1
    if  check == 2:
        break
if check <= 1 or n == 1:
    print("Yes")
else:
    print("No")
#print(list_h)

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

result = "YES"

for i in range( N-2, -1,-1):
  if list[i] > list[i+1]:
    list[i] -=1
    if list[i] > list[i+1]:
      result = "NO"
      break

print(result)

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

result = "YES"

for i in range( N-2, -1,-1):
  if list[i] > list[i+1]:
    list[i] -=1
    if list[i] > list[i+1]:
      result = "NO"
      break

print(result)

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

result = "Yes"

for i in range( N-2, -1,-1):
  if list[i] > list[i+1]:
    list[i] -=1
    if list[i] > list[i+1]:
      result = "No"
      break

print(result)

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 numpy as np
n = int(input())
h = list(map(int, input().split()))

h = np.array(h)

for i in range(len(h)-1):
   if h[i] < h[i+1]:
       h[i+1] -= 1
print(h)
np.diff(h-1, n=1)

minus = [i for i in np.diff(h-1, n=1) if i < 0]

if len(minus) > 0:
    print('No')
else:
    print('Yes')


import numpy as np
 
n = int(input())
hh = np.array([])
for i in range(n):
    hh.append(input())
 
for i in range(len(hh)-1):
   if hh[i] < hh[i+1]:
       hh[i+1] -= 1
np.diff(hh-1, n=1)
 
minus = [i for i in np.diff(hh-1, n=1) if i < 0]
 
if len(minus) > 0:
    print('No')
else:


import numpy as np

n = int(input())
h = []
for i in range(n):
    h.append(input())

for i in range(len(hh)-1):
   if hh[i] < hh[i+1]:
       hh[i+1] -= 1
np.diff(hh-1, n=1)

minus = [i for i in np.diff(hh-1, n=1) if i < 0]

if len(minus) > 0:
    print('No')
else:
    print('Yes')

n = int(input())
h = []
for i in range(n):
    h.append(input())
 

flag = 'Yes'
for i in range(len(h)-1):
    
    if h[i] <= h[i+1]:
        h[i+1] -= 1
        
        if h[i] > h[i+1]:
            if n == i+1:
                break
            flag = 'No'
            break
print(flag)

n = int(input())
h = []
for i in range(n):
    h.append(input())


flag = 'Yes'
for i in range(len(h)-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
        if h[i] < h[i+1]:

            if n == i+1:
                break
            flag = 'No'
            break
print(flag)

n = int(input())
h = []
for i in range(n):
    h.append(input())


flag = 'Yes'
for i in range(len(h)-1):
    
    if h[i] < h[i+1]:
        h[i+1] -= 1
        
        if h[i] > h[i+1]:
            if n == i+1:
                break
            flag = 'No'
            break
print(flag)

import numpy as np
 
n = int(input())
h = list(map(int, input().split()))
 
h = np.array(h)
 
for i in range(len(h)-1):
   if h[i] < h[i+1]:
       h[i+1] -= 1
np.diff(h-1, n=1)
 
minus = [i for i in np.diff(h-1, n=1) if i < 0]
 
if len(minus) > 0:
    print('No')
else:
    print('Yes')

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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

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


n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
flag = True
for i in range(n - 1):
    # print(i)
    if h[i] > h[i + 1]:
        flag = False
        break
    elif h[i] <= h[i + 1] - 1:
        h[i + 1] -= 1

if flag:
    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()))

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

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

for i in range(0, n-1):
    if h[i] > h[i+1] -1:
        print('No')
        break
    h[i+1] -= 1
else:
    print('Yes')

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


h[0] -= 1
for i in range(0, n-1):
    if h[i] <= h[i+1] -1:
        h[i+1] -= 1
    elif h[i] > h[i+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())
h = [int(i) for i in input().split()]
if h[j+1] - h[j] < -1 for j in range(n):
  print("No")
elif h[k+2] < h[k+1] and h[k+1] <= h[k] for k in range(n-1):
  print("No")
else:
  print("Yes")


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


n = int(input())
h = [int(i) for i in input().split()]
for j in range(n):
  if h[j] - h[j+1] > 1:
    print("No")
    exit()
  else:
    h[j] = h[j] -1
  if h[j] > h[j+1]:
    print("No")
    exit()
print("Yes")


n = int(input())
h = [int(i) for i in input().split()]
for j in range(n):
  if h[j] - h[j+1] < -1:
    print("No")
    exit()
  else:
    continue
for k in range(n-1):
  if h[k] < h[k+1] and h[k+1] < h[k+2]:
    print("No")
    exit()
  else:
    continue
print("Yes")


n = int(input())
h = [int(i) for i in input().split()]
for j in range(n):
  if h[j] - h[j+1] > 1:
    print("No")
    exit()
  else:
    continue
for k in range(n-1):
  if h[k] > h[k+1] and h[k+1] > h[k+2]:
    print("No")
    exit()
  else:
    continue
print("Yes")


n = int(input())
h = [int(i) for i in input().split()]
if h[j] - h[j+1] < -1 for j in range(n):
  print("No")
elif h[k+2] > h[k+1] and h[k+1] <= h[k] for k in range(n-1):
  print("No")
else:
  print("Yes")


n = int(input())
h = [int(i) for i in input().split()]
for j in range(n-1):
  for k in range(n-2):
    if (h[j] - h[j+1] < -1) or (h[k] < h[k+1] and h[k+1] < h[k+2]):
      print("No")
      exit()
    else:
      continue
print("Yes")


n = int(input())
h = [int(i) for i in input().split()]
for j in range(n-1):
  if h[j] - h[j+1] < -1:
    print("No")
    exit()
  else:
    continue
for k in range(n-2):
  if  h[k] < h[k+1] and h[k+1] < h[k+2]:
     print("No")
    exit()
  else:
    continue
print("Yes")


n = int(input())
h = [int(i) for in in input().split()]
if h[j+1] - h[j] < -1 for j in range(n):
  print("No")
elif h[k+2] < h[k+1] and h[k+1] <= h[k] for k in range(n-1):
  print("No")
else:
  print("Yes")


n = int(input())
h = [int(i) for i in input().split()]
for j in range(n-1):
  if h[j] - h[j+1] < -1:
    print("No")
    exit()
  else:
    continue
for k in range(n-2):
  if h[k] < h[k+1] and h[k+1] < h[k+2]:
    print("No")
    exit()
  else:
    continue
print("Yes")


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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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()))
for i in range(N-1):
  if H[i]>=H[i+1]:
    H[i]-=1
if H==sorted(H):
  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
if H==sorted(H):
  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()))
h[0] -= 1 if h[0] > 0 else 0
for i in range(1, n):
    if h[i] > h[i-1]:
        h[i] -= 1
    if h[i] < h[i-1]:
        print("NO")
        exit()
print("YES")


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


Verdicts: Wrong Answer

Accepted