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 = [0]*n
for i in range(n):
  h[i] = int(input())
count = True
for i in range(n-1):
  if h[i+1]-h[i] < -1:
    count = False
    break
  elif h[i+1]-h[i] = -1:
    h[i+1] += 1
if count == True:
  print("Yes")
else:
  print("No")

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


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

max_height = 0
for h1, h2 in zip(H[:-1], H[1:]):
  max_height = max(max_height, h1)
  if h1-1 > h2 or max_height > h2:
    print("No")
    break
else:
  print("Yes")
  

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

max_height = 0
for h1, h2 in zip(H[:-1], H[1:]):
  max_height = max(max_height, h1-1)
  if max_height > h2:
    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()))
def is_stairs(h):
    
    if len(h) == 1:
        return('Yes')
    for i in range(2, len(h)):
        if h[i-1] - h[i] > 0:
            return('No')
        h[i] = min(h[i-1],h[i])
    return('Yes')
print(is_stairs(h))

n = int(input())
h = list(map(int, input().split()))
def is_stairs(h):
    
    if len(h) == 1:
        return('Yes')
    h[0] -= 1
    for i in range(1, len(h)):
        if h[i-1] - h[i] > 0:
            return('No')
        h[i] = max(h[i-1],h[i]-1)
        #print(h)
    return('Yes')
print(is_stairs(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):
import numpy as np

n = int(input())
h = np.array([int(i) for i in input().split()])

d = np.diff(h)
dd = np.array([d[i]+d[i+1] for i in range(len(d)-1)])

if n == 1:
  print('Yes')
elif (d>=-1) and (dd>=-1).all():
  print('Yes')
else:
  print('No')

import numpy as np

n = int(input())
h = np.array([int(i) for i in input().split()])

err = 0
f = 0
for i in range(n-1):
  t = h[i+1] - h[i]
  if t>=-1 and f>=-1 and not(t==-1 and f==-1):
    pass
  else:
    err = 1
    break
    
  if t!=0:
    f = t
  
if err==1:
  print('No')
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(1,n):
  if h[i]-h[i-1]>1:
    print('No')
    exit()
  elif h[i]-h[i-1]==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]-h[i-1]<-1 or (i>=2 and h[i]-h[i-1]==-1 and h[i-2]==h[i-1]):
    print('No')
    exit()
  elif i>=2 and h[i-2]<h[i-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()))
import sys

for i in range(n-1,1,-1):
    if max(h[:i])>h[i]+1:
        break
    print(f"{i+1}:ok!")
else:
    print("Yes")
    sys.exit()
print("No")

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

for i in range(n-1):
    if al[i] < al[i+1] -1:
        print("No")
        exit()
    else:
        pass
print("Yes")

n = int(input())
al = list(map(int, input().split()))
cnt = len(al)
tmp = al[cnt-1]

for i in range(cnt-1, 1, -1):
    if al[i-1] - tmp >= 2:
        print("No") 
        exit()
    elif al[i-1] - tmp == 1:
        tmp = al[i-1]-1
    else:
        tmp = al[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()))

H_reversed = list(reversed(H))
for i in range(N):
    if H_reversed[i+1] - H_reversed[i] == 1:
        H_reversed[i+1] -= 1
    elif H_reversed[i+1] - H_reversed[i] > 1:
        print('No')
        break
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:
        print('No')
        break
    if i == 0:
        print('Yes')


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

exit_flag = False
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:
        exit_flag = True
        print('No')
        break

if not exit_flag:
    print('Yes')


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

last = sorted(h)

for i in range(1, n):
    if h[i-1] > h[i]:
        h[i-1] -= 1

if last == sorted(h):
    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-1] <= h[i]:
        continue
    elif h[i-1] == h[i] + 1:
        h[i-1] -= 1
    else:
        print("No")
        exit(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 = list(map(int,input().split()))
frag = 0
tmp = 0

for i in range(0,N):
    if A[i] > A[i+1]:
        A[i] -= 1
        tmp = A[i]
        if A[i-1] > A[i] or tmp > A[i+1]:
            frag += 1
            break

if frag >= 1:
    print("No")
else:
    print("Yes")

N = int(input())
A = list(map(int,input().split()))
frag = 0
tmp = 0
 
for i in range(0,N):
    if A[i] > A[i+1]:
        A[i] = A[i] - 1
        tmp = max(A)
        if A[i] > A[i+1] or tmp > A[i+1]:
            frag += 1
            break
 
if frag == 1:
    print("No")
else:
    print("Yes")

N = int(input())
A = list(map(int,input().split()))
frag = 0
tmp = 0
 
for i in range(0,N-1):
    if A[i] > A[i+1]:
        A[i] = A[i] - 1
        tmp = max(A)
        if A[i] > A[i+1] or tmp > A[i+1]:
            frag += 1
            break
 
if frag >= 1:
    print("No")
else:
    print("Yes")

N = int(input())
A = list(map(int,input().split()))
pre = -999
frag = 0

for i in range(N+1):
    if A[i]-1 >= pre:
        pre = A[i] - 1
    elif A[i] >= pre:
        pre = A[i]
    else:
        frag += 1
        break
        
if frag == 1:
    print("No")
else:
    print("Yes")

N = int(input())
A = list(map(int,input().split()))
pre = -999
frag = 0

for i in range(N):
    if A[i]-1 >= pre:
        pre = A[i] - 1
    elif A[i] >= pre:
        pre = A[i]
    else:
        frag += 1
        break
        
if frag == 1:
    print("No")
else:
    print("Yes")

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

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

def main():
    N = int(input())
    H = [int(x) for x in input().split()]
    H[0] -= 1
    for i in range(1, N - 1):
        if H[i-1] < H[i]:
            H[i] -= 1
        if H[i] > H[i+1]:
            print('No')
            break
    else:
        print('Yes')
    return

main()

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

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

	if flag==0 and H[N-1]>=H[N-2] and H[N-2]>=H[N-3]:
		print("Yes")
	else:
		print("No")
elif N==2:
	if H[N-1]>=H[N-2]:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")


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

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

	if flag==0 and H[N-1]>=H[N-2] and H[N-2]>=H[N-3]:
		print("Yes")
	else:
		print("No")
elif N==2:
	if H[N-2]-H[N-1]<=-1:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")


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

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

	if flag==0 and H[N-1]>=H[N-2] and H[N-2]>=H[N-3]:
		print("Yes")
	else:
		print("No")
elif N==2:
	if H[N-1]-H[N-2]<=1:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")


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

if N>1:
	flag=0
	for i in reversed(range(N-1)):
		if H[i-1]-H[i}>1:
			flag=1
		if H[i-1]-H[i]==1:
			H[i-1] -= 1
	if flag==0:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")


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

if N>1:
	flag=0
	for i in reversed(range(1,N)):
		if H[i-1]-H[i]>1:
			flag=1
		if H[i-1]-H[i]==1:
			H[i-1] -= 1
	if flag==0:
		print("Yes")
	else:
		print("No")
else:
	print("Yes")


Verdicts: Wrong Answer

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

if A[0]-A[1]==1:
  A[0]-=1

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

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

for i in range(N-1):
  if A[N-2-i]-A[N-1-i]==1:
    A[N-2-i]-=1
  elif A[N-2-i]-A[N-1-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 = input()
H = [int(x) for x in input().split()]
C = 0
for i in H:
  if H[i] <= H[i+1]+1:
    C += 1
if C = N:
  print("Yes")
else:
  print("No")

N = int(input())
H = [int(x) for x in input().split()]
C = 0
for i in range(N-1):
  if H[i] <= H[i+1]+1:
    C += 1
if C == N-1 OR C == N:
  print("Yes")
else:
  print("No")


N = int(input())
H = [int(x) for x in input().split()]
C = 0
for i in range(N-1):
  if H[i] > H[i+1]+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 = [int(x) for x in input().split()]
C = 0
for i in range(N-1):
  if H[i] <= H[i+1]+1:
    C += 1
if (C == N-1 OR C == N):
  print("Yes")
else:
  print("No")


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

N = int(input())
H = [int(x) for x in 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

Runtime Error

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):
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
for i in range(N-1):
    if i==0:
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
    if H[i-1]<=H[i]-1<=H[i+1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
H = LI()
for i in range(N-1):
    print(H)
    if i==0:
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


def I(): return int(input())
def LI(): return list(map(int,input().split()))
##################################################
N = I()
H = LI()
for i in range(N):
    if i==0:
        H[i] -= 1
        continue
    if i==N-1:
        if H[i-1]<=H[i]:
            continue
    if H[i-1]<=H[i]-1<=H[i+1]:
        H[i] -= 1
        continue
    if H[i-1]<=H[i]<=H[i+1]:
        continue
    print('No')
    break
else:
    print('Yes')


Verdicts: 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=[int(i) for i in input().split()]
A=1
if N>1:
    for i in range(N-1):
        if H[-(i+1)-1] <= H[-(i+1)]:
            A+=1
            print(A)
        elif H[-(i+1)-1]-1 == H[-(i+1)]:
            A+=1
            H[-(i+1)-1]-=1
    if A==N:
        print('Yes')
    else:
        print('No')
elif N==1:
    print('Yes')

S=list(input())
L=list("L")
R=list("R")
H=[]
H1=[]
H2=[]
A=100000
n=0
for i in range(len(S)):
    H.append(1)
while A != 0:
    H1=H[:]
    for i in range(len(S)):
        if S[i]=="R":
            H[i+1]+=H1[i]
            H[i]-=H1[i]
        elif S[i]=="L":
                H[i-1]+=H1[i]
                H[i]-=H1[i]
    H2=H[:]
    for i in range(len(S)):
        if S[i]=="R":
            H[i+1]+=H2[i]
            H[i]-=H2[i]
        elif S[i]=="L":
            H[i-1]+=H2[i]
            H[i]-=H2[i]
    if H1==H:
        print(" ".join( [str(s) for s in H] ))
        quit()


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


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

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

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()))
f=True

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

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

for i in range(1,n):
	if h[-i]>=h[-i-1]:
		pass
	else:
		h[-i-1]-=1

for i in range(1,n):
	if h[i]>=h[i-1]:
		f=True
	else:
		f=False
		break

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

flag=False

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

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


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

for i in range(N):
    if i==0:
        continue
    if  H[i]<H[i-1]:
        print("No")
        exit()
    if H[i-1]<H[i]:
        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):
# coding: utf-8
N = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(N-1):
    if H[i+1] - H[i] < 0:
        flag = False
        break
print("Yes" if flag else "No")

# coding: utf-8
N = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(1, N):
    if H[i] < H[i-1]:
        flag = False
        break
    else:
        if H[i-1] < H[i]:
            H[i] -= 1
print("Yes" if flag 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):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(N-1):
    if H[i] > H[i+1]:
        if H[i]-1 == H[i+1]:
            ans = 0
            break
print('Yes' if ans==1 else 'No')
print(H)

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

4
1 3 2 1

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

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

Verdicts: Wrong Answer

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())
tall = list(map(int, input().split()))
large = max(tall)
short = min(tall)
frag = 0
lnum = 0
mnum = 0
for i in range(n):
    if(frag == 0):
        if(tall[i] == large):
            lnum = i
            frag = 1
    if(tall[i] == mnum):
        mnum = i


if(n == 1):
    print("Yes")
elif(((large - short)>= 2)and(mnum>lnum)):
    print("Yes")
else:
    print("No")


n = int(input())
tall = list(map(int, input().split()))
lar = tall[0]
lno = 0
frag = 0


for i in range(n):
    if(tall[i]>lar):
        lar= tall[i]
    if(lar - tall[i] >= 2):
        frag = 1
        break

if(frag == 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())
h_list = [int(e) for e in input().split()]
answer = 'Yes'

for i in range(n):
    if h_list[i] > h_list[i+1]:
        h_list[i] -= 1
    if h_list[i] > h_list[i+1]:
        answer = 'No'
        break

print(answer)

n = int(input())
for i in range(n-1, -1, -1):
    if h_list[i]>h_list[i-1]:
        h_list[i-1] -= 1
        if h_list[i] < h_list[i-1]:
            print('No')
            break
else:
    print('Yes')

import sys

n = int(input())
h_list = [int(e) for e in input().split()]
print(h_list)

for i in range(n):
    if i == n-1:
        print('Yes')
        sys.exit()
    else:
        if h_list[i] > h_list[i+1]:
            h_list[i] -= 1
        if h_list[i] > h_list[i+1]:
            print('No')
            sys.exit()

print('Yes')

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

answer = 'Yes'
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]: 
     answer = 'No'
     break

print(answer)

n = int(input())
for i in range(n-1, -1, -1):
    if h_list[i]>h_list[i-1]:
        h_list[i-1] -= 1
        if h_list[i] < h_list[i-1]:
            print('No')
            break
else:
    print('Yes')

n = int(input())
h_list = [int(e) for e in input().split()]
answer = 'Yes'

for i in range(n):
    if h_list[n] <= h_list[n+1]:
        continue
    else:
        h_list[n] -= 1
        if h_list[n] > h_list[n+1]:
            answer = 'No'
            break

print(answer)

import sys

n = int(input())
h_list = [int(e) for e in input().split()]
print(h_list)

for i in range(n):
    if i == n-1:
        print('Yes')
        sys.exit()
    if h_list[i] > h_list[i+1]:
        h_list[i] -= 1
    if h_list[i] > h_list[i+1]:
        print('No')
        sys.exit()

print('Yes')

n = int(input())
h_list = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
    if h_list[i] > h_list[i + 1]:
        h_list[i] -= 1
    if h_list[i] > h_list[i + 1]:
        print('No')
        break
else:
    print('Yes')

Verdicts: Runtime Error

Runtime Error

Wrong Answer

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 itertools
# import math


def solve(N, H):
    for i in range(1, N):
        if H[i] < H[i+1]:
            H[i+1] -= 1
        elif H[i] > H[i+1]:
            return 'No'
    return 'Yes'


N = int(input())
# S = input()
# A, B = map(int, input().split())
H = list(map(int, input().split()))

# P = []
# S = []

#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, H))


# import itertools
# import math


def solve(N, H):
    for i in range(N - 1):
        if H[i] < H[i+1]:
            H[i+1] -= 1
        elif H[i] > H[i+1]:
            return 'No'
    return 'Yes'


N = int(input())
# S = input()
# A, B = map(int, input().split())
H = list(map(int, input().split()))

# P = []
# S = []

#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, H))


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

print('Yes')


       
    


n=int(input())
h=list(map(int,input().split()))
c=0
for i in range(n-1,-1,-1):
  if h[i]<h[i+1]-1:
    print('No')
    exit()
  elif h[i]==h[i+1]-1:
    h[i+1]=h[i+1]-1

print('Yes')


       
    

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


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

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

N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
    if H[i] - H[i+1] > 1:
        print("No")
        quit()

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

for i in range(n-1):
    
    if Hs[i]+1 == Hs[i+1]:
        Hs[i] -= 1

    elif Hs[i] > Hs[i+1]:
        ans = 'No'

print(ans)


n = int(input())
Hs = list(map(int, input().split()))
ans = 'Yes'

for i in range(n-1):
    if Hs[i] > Hs[i+1] + 1:
        ans = 'No'
        break
    elif Hs[i] == Hs[i+1]+1:
        Hs[i+1] += 1

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):
import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
for i in range(n-1):
    dif = h[i] - h[i+1]
    if dif > 1:
        print(ans)
        sys.exit()
    elif dif == 1:
        h[i] -= 1

max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    if dif >= 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)

import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
for i in range(n-1):
    dif = h[i] - h[i+1]
    if dif > 1:
        print(ans)
        sys.exit()
    elif dif == 1:
        h[i] -= 1

max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    if dif > 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)

import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
for i in range(n-1):
    dif = h[i] - h[i+1]
    if dif > 1:
        print(ans)
        sys.exit()
    elif dif == 1:
        h[i] -= 1

max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    print(max_h, dif)
    if dif < 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)

import numpy as np
import sys
n = int(input())
h = np.array(list(map(int, input().split())))
ans = "No"
h[0] -= 1
for i in range(1, n-1):
    dif_1 = h[i] - h[i+1]
    dif_2 = h[i] - h[i-1]
    if dif_1 > 1:
        print(ans)
        sys.exit()
    elif dif_1 == 1 or dif_2 > 0:
        h[i] -= 1


max_h = 0
for i in range(1, n):
    max_h = max(max_h, h[i-1])
    dif = h[i] - max_h
    if dif < 0:
        print(ans)
        sys.exit()
ans = "Yes"
print(ans)

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

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

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


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

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

n = int(input())
h = list(map(int, input().split()))[::-1]
last = h[0]
for i in range(1, n):
  if h[i] <= last:
      last = h[i]
  elif last+1 == h[i]:
      continue
  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):
length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)-1):
  if a_list[i] < a_list[i+1]:
    a_list[i+1] -= 1
  elif a_list[i] > a_list[i+1]:
    print("No")
    exit()
    
print('yes')

length = input()
list = list(map(int, input().split()))
 
for i in range(length):
  if i == (length - 1):
    print('Yes')
    break
  elif (list[i+1] - list[i]) >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

length = input()
a_list = list(map(int, input().split()))
 
for i in range(length):
  if i == (length - 1):
    break
  elif (a_list[i+1] - a_list[i]) >1 :
    a_list[i+1] += 1 
  elif a_list[i+1] >= 1 :
    continue
  elif a_list[i+1] < a_list[i]:
    print("No")
    break



length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)):
  if i == (len(a_list) - 1):
    break
  elif (a_list[i+1] - a_list[i]) >1 :
    a_list[i+1] += 1 
  elif a_list[i+1] >= 1 :
    continue
  elif a_list[i+1] < a_list[i]:
    print("No")
    break

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

for i in range(length):
  if i == (length - 1):
    print('Yes')
    break
  elif (list[i+1] - list[i]) >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

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

for i in range(length):
  if i == length:
    print('Yes')
  elif list[i+1] - list[i] >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

length = int()
list = int().split()

for i in range(length):
  if i == length:
    print('Yes')
  elif list[i+1] - list[i] >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break




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

for i in range(length):
  if i == (length - 1):
    break
  elif (list[i+1] - list[i]) >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)-1):
  if a_list[i] < a_list[i+1]:
    a_list[i+1] -= 1
  elif a_list[i] > a_list[i+1]:
    print("No")
    exit()
    
print('Yes')


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

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):
import sys
def input():
    return sys.stdin.readline()[:-1]

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

flag = False
ok = True
pre = 0

for i in range(N):
    pos = l[i]
    if pos>pre:
        flag = False
    elif pos == pre:
        flag = True
    else:
        if flag:
            ok = False
            break
        else:
            if (pre - pos)==1:
                flag = True
            else:
                ok = False
                break
    print(pre,pos)
    pre = pos
if ok:
    print('Yes')
else:
    print('No')

import sys
def input():
    return sys.stdin.readline()[:-1]

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

flag = False
ok = True
pos = 10**9+7

for i in range(N-1,-1,-1):
    pre = l[i]
    if pos>=pre:
        pass
    else:
        if (pre - pos)==1:
            pre -= 1
        else:
            ok = False
            break
    pos = pre
if ok:
    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()))

res = 'Yes'
hmax = 0
tmp = 0

for i in h:
    if tmp > i:
        hmax = tmp
    if hmax >= i+1:
        res = 'No'
        break
    tmp = i

print(res)

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

res = 'Yes'
hmax = 0
tmp = 0

for i in h:
    if hmax < tmp:
        hmax = tmp
    if hmax >= i+2:
        res = 'No'
        break
    tmp = i

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())
Hn = list(map(int,input().split()))[::-1]
minnum = Hn[0]
check = True
for i in range(1,len(Hn)):
    if Hn[i]-Hn[i-1]<=-1:
        check = False
        break
    elif Hn[i]-Hn[i-1]==-1:
        Hn[i]-=1
    else:
        continue
if check:
    print("Yes")
else:
    print("No")

N = int(input())
Hn = list(map(int,input().split()))[::-1]
minnum = Hn[0]
check = True
for i in range(1,len(Hn)):
    if Hn[i]-Hn[i-1]<-1:
        check = False
        break
    elif Hn[i]-Hn[i-1]==-1:
        Hn[i]-=1
    else:
        continue
if check:
    print("Yes")
else:
    print("No")

N = int(input())
Hn = list(map(int,input().split()))[::-1]
minnum = Hn[0]
check = True
for i in range(1,len(Hn)):
    if Hn[i-1]-Hn[i]<-1:
        check = False
        break
    elif Hn[i-1]-Hn[i]==-1:
        Hn[i]-=1
    else:
        continue
if check:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

Wrong Answer

Accepted