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):
kazu = int(input())
suji = input().split()

l_si_i = [int(s) for s in suji]

if kazu == 1:
    print('Yes')
    exit()

for i in range(kazu):
    if kazu - i != 1:
        if l_si_i[i+1] - l_si_i[i] == 0:
            continue
        elif l_si_i[i+1] - l_si_i[i] == 1:
            continue
        elif l_si_i[i+1] - l_si_i[i] == -1:
            l_si_i[i+1] = l_si_i[i+1] - 1
            continue
        elif l_si_i[i+1] - l_si_i[i] > -1:
            print('No')
            exit()
        else:
            continue

    else:
        print('Yes')
        exit()


kazu = int(input())
suji = input().split()

l_si_i = [int(s) for s in suji]

if kazu == 1:
    print('Yes')
    exit()

for i in range(kazu):
    if i == 0:
        if l_si_i[i+1] - l_si_i[i] == 0:
            continue
        elif l_si_i[i+1] - l_si_i[i] == 1:
            continue
        elif l_si_i[i+1] - l_si_i[i] == -1:
            l_si_i[i] = l_si_i[i] - 1
            continue
        elif l_si_i[i+1] - l_si_i[i] > -1:
            print('No')
            exit()
        else:
            continue

    else:
        if l_si_i[i] - l_si_i[i-1] == 0:
            continue
        elif l_si_i[i] - l_si_i[i-1] == 1:
            continue
        elif l_si_i[i] - l_si_i[i-1] == -1:
            l_si_i[i] = l_si_i[i] - 1
            continue
        elif l_si_i[i] - l_si_i[i-1] > -1:
            print('No')
            exit()
        else:
            continue
print('Yes')

kazu = int(input())
suji = input().split()

l_si_i = [int(s) for s in suji]

for i in range(kazu):
    if kazu - i == 1:
        print('Yes')
    elif i == 0:
        if l_si_i[i+1] - l_si_i[i] < -1:
            print('No')
            exit()
        elif l_si_i[i+1] - l_si_i[i] == -1:
            if l_si_i[i+1] > 1:
                l_si_i[i+1] = l_si_i[i+1] - 1
                continue
            else:
                print('No')
                exit()
        else:
            continue
    else:
        if l_si_i[i+1] - l_si_i[i] == 0:
            if l_si_i[i] - l_si_i[i-1] >= 0:
                continue
            else:
                print('No')
                exit()
                continue
        elif l_si_i[i+1] - l_si_i[i] == 1:
            if l_si_i[i] - l_si_i[i-1] >= 0:
                continue
            else:
                print('No')
                exit()
                continue
        elif l_si_i[i+1] - l_si_i[i] == -1:
            if l_si_i[i] - l_si_i[i-1] <= 0:
                print('No')
                exit()
            else:
                l_si_i[i+1] = l_si_i[i+1] - 1
                continue
        elif l_si_i[i+1] - l_si_i[i] < -1:
            print('No')
            exit()
        else:
            continue


i = int(input())
s = list(map(int, input().split()))
m = 0
a = 'Yes'

for n in range(i):
    if s[n] < (m-1):
        a = 'No'
    m = max(s[n],m)

print(a)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted