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]:
        pass
    elif  H[i] == H[i+1]:
        for k in range(i+1,N-1):
            if H[i] < H[k]:
                pass
            else:
                H[i] = H[i] - 1

    else:
        H[i] = H[i]-1

count = 0
for j in range(N-1):
    if H[j] <= H[j + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("YES")
else:
    print("NO")


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

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


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    elif H[i] == H[i+1]:
        for k in range(i+2, N-1):
            if H[i] < H[k]:
                pass
            else:
                H[i] = H[i] - 1

    else:
        H[i] = H[i]-1

count = 0
for j in range(N-1):
    if H[j] <= H[j + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    else:
        H[i] = H[i]-1


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

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


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

count = 0
for i in range(N-1):
    if H[i+1] - H[i] <= -2:
        count = -1
        break
    else:
        H[i] = H[i]-1

for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    elif H[i] == H[i+1]:
        for k in range(i+2, N-1):
            if H[i] < H[k]:
                pass
            else:
                H[i] = H[i] - 1
                break
    else:
        H[i] = H[i]-1

count = 0
for j in range(N-1):
    if H[j] <= H[j+1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    else:
        H[i] = H[i]-1

count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

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


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

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


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    elif H[i] == H[i+1]:
        for k in range(i+1,N-1):
            if H[i] < H[k]:
                pass
            else:
                H[i] = H[i] - 1

    else:
        H[i] = H[i]-1

count = 0
for j in range(N-1):
    if H[j] <= H[j + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("YES")
else:
    print("NO")


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

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


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    elif H[i] == H[i+1]:
        H[i] = H[i] - 1
    else:
        H[i] = H[i]-1

count = 0
for j in range(N-1):
    if H[j] <= H[j+1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("YES")
else:
    print("NO")

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

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

count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    elif  H[i] == H[i+1]:
        for k in range(i+1,N-1):
            if H[i] < H[k]:
                pass
            else:
                H[i] = H[i] - 1

    else:
        H[i] = H[i]-1

count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    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]:
        pass
    else:
        H[i] = H[i]-1


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

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


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

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


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted