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()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t=h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print(Yes)
else:
    print(No)

n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print(Yes)
else:
    print(No)


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


n=int(input())
a=list(map(int,input().split()))
a.sort()
for i in range(n-1):
  if a[i]+1==a[i+1]:
    a[i+1]-=1
  elif a[i]+1<a[i+1]:
    print("No")
    exit()
  else:
    pass
print("Yes")

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

a.reverse()

for i in range(n-1):
  if a[i]+1==a[i+1]:
    a[i+1]-=1
  elif a[i]+1<a[i+1]:
    print("No")
    exit()
  else:
    pass
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-1,0,-1):
    if H[i] - H[i-1] == -1:
        H[i-1] -= 1
print(H)

for j in range(N-1):
    if H[j] > H[j+1]:
        print('No')
        break
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] == -1:
        H[i-1] -= 1

for j in range(N-1):
    if H[j] > H[j+1]:
        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):
# -*- coding: utf-8 -*-
import sys

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

if int(len(H)) == 1:
	print('Yes')
	sys.exit()

for i in range(N):
	if i == N - 1:
		break
	elif min(H[i],H[i + 1]) == H[i]:
		continue
	elif min(H[i],H[i + 1] - 1) == H[i]:
		H[i + 1] += -1
		continue
	else:
		print('No')
		sys.exit()

print('Yes')

# -*- coding: utf-8 -*-
import sys

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

if int(len(H)) == 1:
	print('Yes')
	sys.exit()

for i in range(N):
	if i == N - 1:
		break
	elif H[i] - 1 < H[i + 1]:
		continue
	else:
		print('No')
		sys.exit()

print('Yes')

# -*- coding: utf-8 -*-
import sys

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

if int(len(H)) == 1:
	print('Yes')
	sys.exit()

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

	check = sorted(H)

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


print('Yes')

# -*- coding: utf-8 -*-
import sys

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

if int(len(H)) == 1:
	print('Yes')
	sys.exit()

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

	check = sorted(H)

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

# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int,input().split()))

ans = 'Yes'
diff = 0

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

	if diff > 1:
		H[i + 1] -= 1
	elif diff < 0:
		ans = 'No'
print(ans)

# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int,input().split()))

ans = 'Yes'
diff = 0

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

	if diff >= 1:
		H[i + 1] -= 1
	elif diff < 0:
		ans = 'No'

print(ans)

Verdicts: Wrong Answer

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):
import sys

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

flag = 0

for i in range(len(H) - 1):
    if H[i] > H[i+1] + 1:
        print('No')
        sys.exit()
	
    elif H[i] = H[i+1] + 1:
	flag = 1
	
    if flag == 1:
        if H[i]	> H[i+1]:
            print('No')
            sys.exit()

print('Yes')

import sys

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

flag = 0

for i in range(len(H) - 1):
    if H[i] > H[i+1] + 1:
        print('No')
        sys.exit()

    elif H[i] == H[i+1] + 1:
        flag = 1

    if flag == 1:
        if H[i] > H[i+1]:
            print('No')
            sys.exit()

print('Yes')

import sys

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

flag = 0

for i in range(len(H) - 1):
    if H[i] > H[i+1] + 1:
        print('No')
        sys.exit()
	
    elif H[i] == H[i+1] + 1:
	flag = 1
	
    if flag == 1:
        if H[i]	> H[i+1]:
            print('No')
            sys.exit()

print('Yes')

File Edit Options Buffers Tools Python YASnippet Help                               
import sys

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

flag = 0

for i in range(len(H) - 1):
    if H[i] > H[i+1] + 1:
        print('No')
        sys.exit()

    elif H[i] == H[i+1] + 1:
        if flag == 0:
            flag = 1
            continue
        else:
            print('No')
            sys.exit()

    if flag == 1:
        if H[i] > H[i+1]:
            print('No')
            sys.exit()
        else:
            flag = 0

print('Yes')

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

flag = 0
key = 0

for i in range(len(H)-1):
    if flag == 1:
        if H[i+1] < key:
            print('No')
            sys.exit()

    if i < len(H) - 1:
        if H[i] > H[i+1] + 1:
            print('No')
            sys.exit()

        elif H[i] == H[i+1] + 1:
            flag = 1
            key = H[i+1]
	
print('Yes')

Verdicts: Runtime Error

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

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

if n == 1:
    ans ='Yes'
for x in range(n-1):
    if h[x] <= h[x+1]:
        ans = 'Yes'
    else:
        ans = 'No'
        break
if h[n-1] <= h[n] and ans ='Yes':
    ans ='Yes'
if h[n-1] <= h[n] and ans ='No'
    ans ='No'

print(ans)

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

for x in range(n-1):
    if h[x] <= h[x+1]:
        pass
    else:
        h[x] = h[x]-1

if n == 1:
    ans ='Yes'
for x in range(n-1):
    if h[x] <= h[x+1]:
        ans = 'Yes'
    else:
        ans = 'No'
        break
if h[n-1] <= h[n] and ans ='Yes':
    ans ='Yes'
if h[n-1] <= h[n] and ans ='No'
    ans ='No'

print(ans)

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


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

for x in range(n-1):
    if h[x] <= h[x+1]:
        pass
    else:
        h[x] = h[x]-1

if n == 1:
    ans ='Yes'
for x in range(n-1):
    if h[x] <= h[x+1]:
        ans = 'Yes'
    else:
        ans = 'No'
        break
if h[n-1] <= h[n] and ans ='Yes':
    ans ='Yes'
if h[n-1] <= h[n] and ans ='No':
    ans ='No'

print(ans)

N = int (input())
H = list(map(int,input().split()))
ans = 'Yes'
for  i in range(N-1):
    diff = H[i+1] - H[i]
    if diff >= 1:
        H[i+1] -= 1
    elif diff < 0:
        ans ='No'
print(ans)


Verdicts: 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):
a = int(input())
h = list(map(int, input().strip().split()))

c = 0

if len(h) == 1:
    c = 1
elif len(h) == 2:
    if h[1] >= h[0]:
        c = 1
    else:
        if h[0] == h[1] + 1:
            c = 1
        else:
            c = -1
else:
    for i in range(len(h)-3):
        if h[i] == h[i+1] and h[i+1] == h[i+2]:
            c = 1
        elif h[i] == h[i+1] and h[i+1] < h[i+2]:
            c = 1
        elif h[i] < h[i+1] and h[i+1] == h[i+2]:
            c = 1
        elif h[i] < h[i+1] and h[i+1] < h[i+2]:
            c = 1
        elif h[i] == h[i+1] + 1 and h[i+1] < h[i+2]:
            c = 1
            h[i] -= 1
        elif h[i] + 1 ==  h[i+1] and h[i+1] == h[i+2] + 1:
            c = 1
            h[i+1] -= 1
        else:
            c = -1
            break

#print(h)
if c > 0:
    print('YES')
else:
    print('NO')


a = int(input())
h = list(map(int, input().strip().split()))



c = 0


d = [0] * len(h)

f = True
if len(h) == 1:
    f = True
elif len(h) == 2:
    if h[1] >= h[0]:
        f = True
    else:
        if h[0] == h[1] + 1:
            f = True
        else:
            f = False
else:
    for i in range(len(h)-1):
        if h[i] + 1 <= h[i+1]:
            #print('c1')
            if d[i+1] == 0:
                h[i+1] -= 1
                d[i+1] = 1
        elif h[i] == h[i+1] + 1:
            #print('c2')
            if i >= 1:
                if h[i-1] + 1 <= h[i]:
                    #print(i,h[i-1],h[i])
                    if d[i] == 0:
                        h[i] -= 1
                        d[i] = 1
                    else:
                        f = False
                        break
                    #print('sub')
                else:
                    #print('c2-2')
                    f = False
                    break
        else:
            #print('c3')
            if not h[i] == h[i+1]:
                #print('c4')
                f = False
                break
        #print(i,h)
#print(h)
if f:
    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()))

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(s[i], minimum)
  if s[i] > minimum + 1:
    print("No")
print("Yes")

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

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(s[i], minimum)
  if s[i] > minimum + 1:
    print("No")
print("Yes")

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

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(h[i], minimum)
  if h[i] > minimum + 1:
    print("No")
    exit()
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())
L = list(map(int, input().split()))

for i in L:
  for k in L[1:]:
    if i<=k || i-1<=k:
      ans=yes
    else:
      ans=no
      
print(ans)

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

for i in L:
  for k in L[1:]:
    if i<=k || i-1<=k:
      ans="yes"
    else:
      ans="no"
      
print(ans)


N=int(input())
H=list(map(int, input().split()))
maxv=H[0]
ans="Yes"
for i in range(1, N):
  if maxv-H[i]>=2:
    ans="No"
    break
  maxv=max(maxv, H[i])
print(ans)

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


N = int(input())
H = list(map(int, input().split()))
count = True
m = 0
for i in range(N):
    if H[i] > m:
        m = H[i]-1
    elif H[i] == m:
        continue
    else:
        count = False
        break

print("Yes" if count 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):
import sys

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


import sys

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

for i in range(N):
  ans='YES'
  if N == 1:
    ans='YES'
    break;
  if i== 0:
    H[i]-=1
    continue
    
  if H[i-1] < H[i]:
    H[i] -= 1
  elif H[i-1]==H[i]:
    continue
  else:
    ans = "NO"
    break;
print(ans)

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

ans=1
for i in range(0,N-1):
  if H[i]-max(H[:i+1])<-1:
    ans = 0
    print("NO")
    break;
if ans:
	print("YES")

N=int(input())
H=list(map(int,input().split()))
ans="YES"
for i in range(N):
  if i == 0:
    ans='YES'
  if H[i-1] < H[i]:
    H[i] -= 1
  elif H[i-1]==H[i]:
    continue
  else:
    ans = "NO"
    break;
print(ans)

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

for i in range(N):
  if i == 0:
    ans=='YES'
  if H[i-1] < H[i]:
    H[i] -= 1
  elif H[i-1]==H[i]:
    continue
  else:
    ans = "NO"
    break;
print(ans)

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

for i in range(N):
  if i == 0:
    ans='YES'
  if H[i-1] < H[i]:
    H[i] -= 1
  elif H[i-1]==H[i]:
    continue
  else:
    ans = "NO"
    break;
print(ans)

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

ans=1
for i in range(0,N-1):
  if H[i]-min(H[i+1:])>1:
    ans = 0
    print("NO")
    break;
if ans:
	print("YES")

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

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

if ans:
	print("YES")
else:
	print("No")

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

ans=1
for i in range(0,N-1):
  if max(H[:i+1])-min(H[i+1:])>2:
    ans = 0
    print("NO")
    break;
if ans:
	print("YES")

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

for i in range(N):
  ans='Yes'
  if N == 1:
    ans='Yes'
    break;
  if i== 0:
    H[i]-=1
    continue
    
  if H[i-1] < H[i]:
    H[i] -= 1
  elif H[i-1]==H[i]:
    continue
  else:
    ans = "No"
    break;
print(ans)

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):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())


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

flg = 1

for i in range(1,N):
    if (H[i]-H[i-1])==1:
        H[i]-=1
    elif (H[i]-H[i-1])>=2:
        flg = 0
        break

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

#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())


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

flg = 1

for i in range(1,N):
    if (H[i]-H[i-1])==1:
        H[i]-=1
    elif (H[i]-H[i-1])>=2:
        flg = 0
        break

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

#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())


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

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

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

for i in range(N - 1):
    if H[i + 1] - H[i] == -1:
        H[i + 1] -= 1
    elif H[i + 1] - H[i] > -1:
        print('No')
        exit()
print('Yes')

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

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

sa = []

for i in range(n-1):
    sa.append(h[i+1]-h[i])

#print(sa)

ans = 0
for i in range(n-1):
    if sa[i] == 0 and sa[i+1] < 0:
        print('No')
        exit(0)
    else:
        if sa[i] == -1:
            ans += 1
        elif sa[i] >= 0:
            ans += sa[i]
        else:
            ans += 999
    
    if ans > 1:
        print('No')
        exit(0)
        
#print(ans)
print('Yes')

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

ans = 0
n_max = 0
for i in range(n-1):
    if h[i] > h[i+1]:
        
        if h[i]-1 > h[i+1]:
            ans += 2
        
        
        elif h[i]-1 == h[i+1]:
                ans += 1
    
    elif h[i] < h[i+1]:
        if ans > 0:
            ans -= 1
        
    elif h[i] == h[i+1]:
        ans += 1 
        
    if ans > 1:
        break

#print(ans)
if ans <= 1:
    print('Yes')
else:
    print('No')

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

minHs = []
for i in range(N-1):
    minHs.append(min(H[i+1:]))

res = 'YES'
for i in range(N-1):
    if H[i] - minHs[i] >= 2:
        res = 'No'
        break

print(res)

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

res = 'Yes'
maximum = 0
for i in range(N - 1):
    if maximum < H[i]:
        maximum = H[i]
    if maximum - H[i+1] >= 2:
        res = 'No'

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())
h = list(map(int,input().split()))
lowest = h[i]
for i in range(1,n):
  if h[i] < lowest - 1:
    print("No")
    quit()
  else:
    lowest = max(lowest,h[i]-1)
print("Yes")

n = int(input())
h = list(map(int,input().split()))
lowest = h[0]-1
for i in range(1,n):
  if h[i] < lowest:
    print("No")
    quit()
  else:
    lowest = max(lowest,h[i]-1)
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())
stair = list(map(int, input().split()))

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d > 1:
        print("No")
        exit()
    elif d == 1:
        stair -= 1
print("Yes")


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

for i in reversed(range(1, n)):
    d = stair[i] - stair[i - 1]
    if d < -1:
        print("No")
        exit()
    elif d == -1:
        stair[i - 1] -= 1
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(" ")))

def fun(lst):
    if len(lst) == 1:
        return "Yes"
    for i in range(1,len(lst)-1):
        if lst[i] <= lst[i-1] or lst[i] >= lst[i+1]:
            if lst[i]-1 >= lst[i-1] and lst[i]-1 <= lst[i+1]:
                lst[i] = lst[i]-1
            else:
                return "No"
    return "Yes"


print(fun(H))

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

def fun(lst):
    if len(lst) == 1:
        return "Yes"
    for i in reversed(range(1,len(lst))):
        
        if lst[i-1] - lst[i] == 1:
            lst[i-1] = lst[i-1]-1
        if lst[i-1] <= lst[i]:
            pass
        else:
            return "No"
    return "Yes"

print(fun(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, *a = [*open(0)]

if n==1:
    print('Yes')
    exit()
    
a = [int(i) for i in "".join(a).replace(" ", "")]
for i, x in enumerate(a[:-1]):
    if x-1 > a[i+1]:
        print('No')
        exit()
    
print('Yes')


n = int(input())
h = list(map(int, input().split()))
 
for i in reversed(range(1,n)):
    if h[i] < h[i-1]:
        h[i-1] -= 1
        if h[i] < h[i-1]:
            print("No")
            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())
A = list(map(int, input().split()))
max = A[0]

if N >=2:
    for i in range(N-1):
        if A[i] <= A[i+1] & A[i+1] >= max:
            max=A[i]
            
        elif A[i] - A[i+1] == 1 & A[i+1] >= max:
            A[i] -=1
            max=A[i]
        else:
            print("No")
            break
        
        if i == N-1:
            print("Yes")
else:
    print('Yes')

N = int(input())
A = list(map(int, input().split()))
max = A[0]-1

if N >=2:
    for i in range(N-1):
        
        if A[i] <= A[i+1] & A[i] >= max :
            max=A[i]
            
        elif A[i] - A[i+1] == 1 & A[i]-1 >= max:
            A[i] -=1
            max=A[i]
        else:
            print("No")
            break
        
        if i == N-2:
            print("Yes")
else:
    print('Yes')

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



for i in range(N-1):
    #print(i, max, N, A[i], A[i+1])
    if A[i] - A[i+1] >=2:
        print('No')
        break
    
    if A[i] - A[i+1] ==1 and i >=2 and A[i-1] >= A[i]:
        print("No")
        break
    
    if i ==0 or A[i] > A[i-1]:
        A[i] -=1
        
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 = input().split()
H = [int(i) for i in h]
def is_non_decrease(H):
    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            return False
    return True
    
def improve(H, v):
    for i in range(len(H)-1):
        if H[i] > H[i+1] and not v[i]:
            H[i] = H[i] - 1
            v[i] = True
            break
    return H, v
    
def is_same(v_1, v_2):
    for i in range(len(v_1)):
        if v_1[i] != v_2[i]:
            return False
    return True

v = [False for i in range(N)]
is_yes = True
for i in range(N):
    if is_non_decrease(H):
        break
    H, v_new = improve(H, v)
    if is_same(v_new, v):
        is_yes = False
        break
if is_yes:
    print("Yes")
else:
    print("No")

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

def is_non_decrease(H):
    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            return False
    return True
    
def improve(H, v):
    for i in range(len(H)-1):
        if H[i] > H[i+1] and not v[i]:
            H[i] = H[i] - 1
            v[i] = True
            break
    return H, v
    
def is_same(v_1, v_2):
    for i in range(len(v_1)):
        if v_1[i] != v_2[i]:
            return False
    return True

v = [False for i in range(N)]
is_yes = True
for i in range(N):
    if is_non_decrease(H):
        break
    H, v_new = improve(H, v)
    if is_same(v_new, v):
        is_yes = False
        break
    v = v_new
if is_yes:
    print("Yes")
else:
    print("No")

N = int(input())
#h = map(int, input().split())
h = input().split()
H = [int(i) for i in h]
for i in reversed(range(N-1)):
    if H[i] > H[i+1]:
        H[i] -= 1
is_yes = True
for i in range(N-1):
    if H[i] > H[i+1]:
        is_yes = False
        break
if is_yes:
    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):
n=int(input())
arr=list(map(int,input().split()))
for i in range(n-1,0,-1): 
 if arr[i]>arr[i-1]: 
   arr[i-1]-=1
   if arr[i]>arr[i-1]: 
     print('No')
     break
else:
 print('Yes')

n=int(input())
arr=list(map(int,input().split()))
for i in range(n-2,-1,-1):
  if arr[i]>arr[i+1]:
    arr[i]-=1
    if arr[i]>arr[i+1]:
      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()))

for i in range(1, n):
    if h[i] <= h[i-1] and h[i-1] != 0:
        h[i-1] = h[i-1] -1

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

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


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

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


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

ans = "Yes"
for i in range(N):
  if i == 0:
    H[0] -= 1
  else:
    if H[i-1] ==  H[i]:
      H[i-1] = H[i]
    elif H[i-1] > H[i]-1:
      print(i)
      ans = "No"
      break
    else:
      if H[i-1] <= H[i]-1:
        H[i] -= 1

print(H)

print(ans)


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

ans = "Yes"

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

print(ans)


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

ans = "Yes"

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

print(ans)


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(1,n):
  if h[i-1]>=h[i]:
    h[i-1]-=1
for i in range(1,n):
  if h[i]<h[i-1]:
    print('No')
    exit()
print('Yes')

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

n=int(input())
h=list(map(int,input().split()))
for i in range(1,n):
  if h[n-i]<h[n-i-1]:
    h[n-i-1]-=1
for i in range(1,n):
  if h[i]<h[i-1]:
    print('No')
    exit()
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):
from collections import deque

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

prev = H.popleft()

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

for i in range(N-1):
    cor = H.popleft()
    if prev - cor < -1:
        print('No')
        exit()
    
    prev = cor


print('Yes')


from collections import deque

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

ato = H.pop()

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

for i in range(N-1, 0, -1):
    mae = H.pop()
    if ato - mae < -1:
        print('No')
        exit()
    elif ato - mae == -1:
        ato = mae - 1
    else:
        ato = mae

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, 0, -1):
    if h[i-1] - h[i] ==1:
        h[i-1]-= 1
    elif h[i-1] -h[i ]> 1:
        flag = False
        print("No")
        break
else:
    print("Yes")

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

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

n = int(input())
h = [int(x) for x in input().split(" ")]
 
for i in range(1, n):
  if h[-i]-h[-i-1] >= 0:
    continue  
  elif h[-i]-h[-i-1] == -1:
    h[-i-1] = h[-i-1] - 1
    continue
  elif h[i]-h[-i-1] < -1:
    ans = "No"
    break
else:
  ans = "Yes"

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

for i in range(1, n):
  if h(-i)-h(-i-1) >= 0:
    continue  
  if h(-i)-h(-i-1) == -1:
    h(-i-1) = h(i-1) - 1
    continue
  if h(i)-h(-i-1) < -1:
    ans = "No"
    break
else:
  ans = "Yes"

print(ans)

n = int(input())
h = [int(x) for x in input().split(" ")]
 
for i in range(1, n):
  if h[-i]-h[-i-1] >= 0:
    continue  
  elif h[-i]-h[-i-1] == -1:
    h[-i-1] = h[-i-1] - 1
    continue
  elif h[-i]-h[-i-1] < -1:
    ans = "No"
    break
else:
  ans = "Yes"
  
print(ans)

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

if H[0]-H[1] <= -1:
    H[1] -= 1
elif H[0]-H[1] = 0:
    H[0] -= 1
    H[1] -= 1
elif H[0]-H[1] = 1:
    H[0] -= 1
else:
    print("No")

for i in range(1, N):
    if i = N-1:
        print("Yes")
        break
    elif H[i]-H[i+1] <= -1:
        H[i+1] -= 1
        continue
    elif H[i]-H[i+1] = 0:
        continue
    elif:
        print("No")
        break


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

if N == 1:
    print("Yes")
elif H[0]-H[1] <= -1:
    H[1] -= 1
elif H[0]-H[1] == 0:
    H[0] -= 1
    H[1] -= 1
elif H[0]-H[1] == 1:
    H[0] -= 1
else:
    print("No")

if N >=　3:
    for i in range(1, N):
        if i == N-1:
            print("Yes")
            break
        elif H[i]-H[i+1] <= -1:
            H[i+1] -= 1
            continue
        elif H[i]-H[i+1] == 0:
            continue
        else:
            print("No")
            break


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

if H[0]-H[1] <= -1:
    H[1] -= 1
elif H[0]-H[1] == 0:
    H[0] -= 1
    H[1] -= 1
elif H[0]-H[1] == 1:
    H[0] -= 1
else:
    print("No")

for i in range(1, N):
    if i == N-1:
        print("Yes")
        break
    elif H[i]-H[i+1] <= -1:
        H[i+1] -= 1
        continue
    elif H[i]-H[i+1] == 0:
        continue
    elif:
        print("No")
        break


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

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

if N == 2:
    if H[0]-H[1] <= -1:
        print("Yes")
    else:
        print("No")

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

        if i == N-1:
            print("Yes")
            break
        elif H[i]-H[i+1] <= -1:
            H[i+1] -= 1
            continue
        elif H[i]-H[i+1] == 0:
            continue
        else:
            print("No")
            break


Verdicts: 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()))
f = 0
if n ==1:
    print("Yes")
else:
    for i in range(1, n):
        if H[i+1] - H[i] < 0:
            H[i] -= 1
            if H[i-1] > H[i] or H[i+1] - H[i] < 0:
                f = 1
                break
    if f == 0:
        print("Yes")
    else:
        print("No")

n = int(input())
H = list(map(int, input().split()))
flag = 0

for i in range(n):
    if H[n-2-i] > H[n-1-i]:
        H[n-2-i] -= 1
        if H[n-2-i] > H[n-1-i]:
            flag = 1
            break

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

n = int(input())
H = list(map(int, input().split()))
flag = 0

if n == 1:
    flag = 0
else:
    for i in range(n-1):
        idx = n-1-i
        if (H[idx-1] - H[idx]) == 1:
            H[idx-1] -= 1
        elif (H[idx-1] - H[idx]) > 1:
            flag = 1
            break

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

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

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

for i in range(n-1):
  a = h[i+1] - h[i] 
  if a < 0:
    print('No')
    exit()
  if a >= 1:
    h[i+1] -= 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()))

flag = 0
for i in range(H.index(max(H))+1, N):
    if max(H)-1 > H[i]:
        flag += 1
        break

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

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

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

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

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

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

for i in range(H.index(max(H))+1, N):
    if max(H)-1 > H[i] and H[i] -H[i-1]:
        print('No')
        exit()
print('Yes')

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

maxH = H[0]
for i in range(1,N):
    if maxH-1 > H[i]:
        print('No')
        exit()
    else:
        maxH = max(H[i], maxH)
print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted