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 = []
H = input().split(" ")
for i in range(N):
    H[i] = int(H[i])

ochinchin = True
for i in range(1, N-1):
    if H[i]<H[i-1]:
        H[i-1] -= 1
        if H[i]<H[i-1]:
            ochinchin = False
            break
        elif i > 2:
            if H[i-1]<H[i-2]:
                ochinchin = False
                break

N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-1):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i+1] >= A[i]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N:
    print("Yes")
else:
    print("No")

N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-1):

    if A[i+1] > A[i]:
        if A[i+1] == A[i]+1:
            A[i+1] -= 1
            chinpo += 1
        else:
            print("No")
            break
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")


N = int(input())
A = map(int, input().split())
chinpo = 0

for i in range(N-1):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i+1] >= A[i]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")
else:
    print("No")

N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-1):

    if A[i+1] > A[i+2]:
        A[i+1] -= 1
        if A[i+2] >= A[i+1]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")
else:
    print("No")

N = int(input())
A = list(map(int, input().split()))
chinpo = 0

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

if chinpo == N-1:
    print("Yes")
else:
    print("No")

N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-2):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i+1] >= A[i]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")
else:
    print("No")

N = int(input())
A = list(map(int, input().split()))
chinpo = 0

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

if chinpo == N-1:
    print("Yes")
else:
    print("No")




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

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

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


N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i] <= A[i+1]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")
else:
    print("No")



N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-2):

    if A[i] > A[i+1]:
        if A[i] == A[i+1]+1:
            A[i] -= 1
            chinpo += 1
        else:
            print("No")
            break
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")



from sys import stdin
N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-2):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i] == A[i+1]:
            chinpo += 1
        else:
            print("No")
            break
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")




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

ochinchin = True
for i in range(1, N):
    if H[i]<H[i-1]:
        H[i-1] -= 1
    if H[i]<H[i-1]:
        ochinchin = False
        break
    else:
        if H[i-1]<H[i-2]:
            ochinchin = False
            break

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


N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(1,N-1):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i] <= A[i+1]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")
else:
    print("No")


N = int(input())
A = list(map(int, input().split()))
chinpo = 0

for i in range(N-2):

    if A[i] > A[i+1]:
        A[i] -= 1
        if A[i] <= A[i+1]:
            chinpo += 1
    else:
        chinpo += 1

if chinpo == N-1:
    print("Yes")
else:
    print("No")


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

ochinchin = True
for i in range(1, N):
    if H[i] < H[i-1]:
        H[i] += 1
        if H[i] < H[i-1]:
            ochinchin = False
            break
            

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted