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

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

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

else :
    print("No")

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

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

if (ans == 1):
    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()))
a = "Yes"

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

for i in range(N-1):
  if H[i]>H[i+1]:
    a = "No"

print(a)


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

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

for i in range(N-1):
  if H[i]>H[i+1]:
    a = "No"

print(H)

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

for h in H:
  if h<a:
    print("No")
    exit()
  a = max(a,h-1)

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

ans = True

n = 4
h = [1,3,2,1]
for i in range(1,n):
    
    if h[i-1] > h[i]:
        h[i-1] -= 1
        if h[i-1] > h[i]:
            ans = False
            break
for i in range(1,n):
    
    if h[i-1] > h[i]:
        ans = False

if ans:
    print('Yes')
else:
    print('No')


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

ans = True

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

if ans:
    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())
height = list(map(int,input().split()))
for i in range(N-1,0,-1):
    print(i)
    n = height[i] - height[i-1]
    if n <= -2:
        print("No")
        exit()
    elif n == -1:
        height[i-1] -= 1

print("Yes")

N = int(input())
height = list(map(int,input().split()))
for i in range(N-1,0,-1):
    n = height[i] - height[i-1]
    if n <= -2:
        print("No")
        exit()
    elif n == -1:
        height[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 = [int(n) for n in input().split()]
m = H[N-1]
for i in range(0, N-1)[::-1]:
    if H[i] > m+1:
        return 'No'
    else:
        m = H[i]
return 'Yes'


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


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

pre0_j = h_list[0]
pre_j = h_list[0]
f = 0
for j in h_list[1:]:
    if pre0_j > j or pre_j > j:
        f = 1
        break
    else:
        pre_j = j

if f == 1:
    print('No')
else:
    print('Yes')

N = int(input())

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

pre_j = h_list[0]
f = 0
for j in h_list[1:]:
    if pre_j > j:
        f = 1
        break
    else:
        if pre_j < j:
            pre_j = j - 1

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

mini = h[0]
for i in range(1,n-1):
    
    if h[i]-1 > mini:
        print("No")
        exit()
    else:
        mini = h[i]
        
if h[n] <= h[n-1]:
    print("No")
    exit()
    
print("Yes")

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

prev = -999
for i in range(n):
    if prev <= h[i]-1: prev = h[i]-1
    elif prev <= h[i]: prev = h[i]
    else:
        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())
hn = [int(num) for num in input().split()]

answer = 0
count = 0

if len(hn) != 1:  
  for h in range(len(hn)-1,0,-1):
    if hn[h] - hn[h-1] == 0:
      pass
    elif hn[h] - hn[h-1] == 1:
      hn[h-1] -= 1
    else :
      print("No")
      break
    if h == 1:
      print("Yes")
else :
  print("Yes")

n = int(input())
hn = [int(num) for num in input().split()]

for i in range(n-1,0,-1):
  if hn[i-1] > hn[i]:
    hn[i-1] -= 1
    if hn[i-1] > hn[i]:
      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()))
print(H[-1])
print(max(H))
if abs(H[-1] - max(H)) >= 2:
    print('No')
else:
    print('Yes')


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

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

if H == 2 and H[0] <= H[1]:
  print('Yes')
  exit()
elif H == 2 and H[0] > H[1]:
  print('No')
  exit()

for i in range(1, N-1):
  # 4,4,4(4,4,5 4,5,5 5,5,5) or 4,5,4
  if H[i-1] <= H[i] <= H[i+1] or H[i-1] <= H[i] - 1 <= H[i+1]:
    pass
  # 5,4,4 or 5,5,4
  elif H[i-1] - 1 <= H[i] <= H[i+1] or H[i-1] - 1 <= H[i] - 1 <= H[i+1]:
    passz
  # 5,4,5
  elif H[i-1] - 1 <= H[i] <= H[i+1] - 1:
    pass 
  else:
    print('No')
    exit()

print('Yes')

# ans

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

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

for i in range(1, N):
  if H[i-1] == H[i]:
    pass
  elif H[i-1] < H[i]:
    H[i] -= 1
  else:
    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())
cells = list(map(int, input().split()))
count = []

for i in range(N-2):
    if cells[N - 1 - i] - cells[N - 2 - i] <= -2:
        print('No')
        break
    elif cells[N - 1 - i] - cells[N - 2 - i] == -1:
        cells[N - 2 - i] = cells[N - 2 - i] - 1
    else:
        count.append('o')
        continue

if len(count) == N - 2:
    print('Yes')

N = int(input())
cells = list(map(int, input().split()))
count = []
if N == 1:
    print('Yes')
else:
    for i in reversed(range(1, N)):
        if cells[i] <= cells[i - 1] - 2:
            print('No')
            break
        elif cells[i] == cells[i - 1] - 1:
            count.append('o')
            cells[i - 1] = cells[i - 1] - 1
        else:
            count.append('o')
    if len(count) == N - 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()))
for i in range(N):
    if i < N - 2:
        elif H[i] > H[i + 1] > H[i + 2]:
            print("No")
            exit()
    elif i < N - 1:
        if H[i] > H[i + 1] + 1:
            print("No")
            exit()
print("Yes")


N = int(input())
H = list(map(int, input().split()))
for i in range(1, N):
    M = max(M, H[i - 1])
    if H[i] < M - 1:
        print("No")
        exit()
print("Yes")


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


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


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()))
diff = []


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

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

for i in range(n-2):
    if diff[i] == -1 and diff[i+1] == -1:
        print('No')
        exit()

if h[-1] - h[0] <=2:
    print('No')
    exit()

print('Yes')

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

h[0] = h[0] - 1

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

if h[0] <= h[-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())
hs = list(map(int, input().split()))
prev_prev = -1
prev = -1
flag = False
for v in hs:
    print(prev_prev, prev, v)
    if v <= prev - 1 and v < prev_prev - 1:
        flag = True
        break
    prev_prev = prev
    prev = v
if flag:
    print('No')
else:
    print('Yes')


n = int(input())
hs = list(map(int, input().split()))
max = hs[0]
prev = -1
flag = False
for v in hs:
    if v <= prev - 1 and v < max - 1:
        flag = True
        break
    if v > max:
        max = v
    prev = v
if flag:
    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(map(int, input().split()))
for i in range(1, n):
    if h[i]<h[i-1]:
        h[i] -= 1
        if h[i]<h[i-1]:
            print('No')
            exit()
print('Yes')

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

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

flag = True
memo = h[0]

for i in range(n-1):
  if h[i] >= h[i+1]:
    h[i] -= 1
    if h[i] < memo:
      flag = False
      break
    elif h[i] == h[i + 1]:
      memo = h[i + 1]
      continue
    else:
      flag = False
      break

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

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

flag = True
level = h[0]

for i in range(n-1):
  if h[i] < h[i+1]:
    pass
  elif h[i] == h[i+1]:
    if level > h[i] - 1:
      pass
    else:
      h[i] -= 1
  else:
    if level > h[i] - 1:
      flag = False
      break
    else:
      h[i] -= 1
      if h[i] == h[i+1]:
        level = h[i]
      else:
        flag = False
        break

if flag:
  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()))

for i in range(1,n-1):
    if h[i-1] <= h[i] <= h[i+1]:
        continue
    else:
        if h[i]>h[i+1]:
            h[i] -= 1
            if h[i]< h[i-1]:
                print('No')
                exit()

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

print('Yes')

n = int(input())
h = list(map(int,input().split()))
m = h[0]
for i in range(1,n):
    m = max(m,h[i])
    if h[i] >= m-1:
        continue
    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_list = list(map(int, input().split()))
H_edit_list = [0, 0]

for h in H_list:
    if h - H_edit_list[-1] <= 0:
        H_edit_list[-1] -= 1
    if H_edit_list[-2] > H_edit_list[-1]:
        print('No')
        exit()
    H_edit_list.append(h)

if H_edit_list[-2] > H_edit_list[-1]:
    print('No')
else:
    print('Yes')        
        
        

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

prev_H = [H_list[0], H_list[1]]

for index, h in enumerate(H_list[2:], 2):
    if h - prev_H[0] < 0:
        H_list[index - 1] -= 1
    prev_H[0] = H_list[index - 1]
    prev_H[1] = H_list[index - 2]
    if prev_H[0] < prev_H[1]:
        print('No')
        exit()

print('Yes')   

N = input()
H_list = list(map(int, input().split()))
H_edit_list = [0, 0]

for h in H_list:
    if h - H_edit_list[-1] <= 0:
        H_edit_list[-1] -= 1
    if H_edit_list[-2] > H_edit_list[-1]:
        print('No')
#         exit()
    H_edit_list.append(h)

if H_edit_list[-2] > H_edit_list[-1]:
    print('No')
else:
    print('Yes')        
        
        

N = input()
H_list = list(map(int, input().split()))
H_edit_list = [10**10]

for h in list(reversed(H_list)):
    if h - H_edit_list[-1] > 0:
        H_edit_list.append(h - 1)
    else:
        H_edit_list.append(h)
    if H_edit_list[-2] < H_edit_list[-1]:
        print('No')
        exit()

print('Yes')       

Verdicts: 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 sys

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

for x in range(n-1)
  	if nums[x] > nums[x+1]:
    	nums[x] -= 1

    if nums[x] > nums[x+1]:
      	print('No')
      	sys.exit()

print('Yes')

import sys

input = sys.stdin.readline
_ = int(input())
nums = map(int, input().split())
maxnum = 0

for x in nums:
    if maxnum < x:
        maxnum = x
    if maxnum - x > 1:
        print('No')
        sys.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):
#python3
n=int(input())
h=[int(i) for i in input().split()]

ok = True
for i in range(n-1):
  if not (h[i] <= h[i+1]):
    ok = False

if ok:
  print('Yes')
else:
  print('No')

#python3
n=int(input())
h=[int(i) for i in input().split()]

def solve():
  h[0]-=1
  for i in range(1,n):
    if h[i] > h[i-1]:
      h[i]-=1
    elif h[i] == h[i-1]:
      pass
    else :
      return 0
  return 1
    

if solve():
  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):
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input().split())
    arr = list(map(int, input().split()))
    
    ok = 1
    for i in reversed(range(n - 1)):
        if arr[i] > arr[i + 1]:
            arr[i] -= 1
        if arr[i] > arr[i + 1]:
            ok = 0
    
    if ok:
        print("Yes")
    else:
        print("No")
    
    return 0

main()

def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    
    ok = 1
    for i in reversed(range(n - 1)):
        if arr[i] > arr[i + 1]:
            arr[i] -= 1
        if arr[i] > arr[i + 1]:
            ok = 0
    
    if ok:
        print("Yes")
    else:
        print("No")
    
    return 0

main()

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):
5
1 2 1 1 3

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    for i in range(1, N):
        if A[i - 1] > A[i]:
            return "No"
        elif A[i] != A[i - 1]:
            A[i] -= 1
    return "Yes"
print(main())


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

N=int(input())
s=list(map(int,input().split()))
ok=True
isitok=0
if N>=2:

    for num in range(N-1):
        if s[num+1]-s[num]<=-2:    
            ok=False
            break
        if s[num+1]-s[num]==-1:
            isitok+=1
        if s[num+1]==s[num]:
        
            continue
        if s[num+1]>s[num]:
            isitok=0
            
        if isitok==2:
            ok=False
            break
        else:
            continue
    if ok:
        print("Yes")
    else:
        print("No")
        
elif N==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[0] -= 1
for i in range(1, n):
    if H[i] < H[i-1]:
        H[i] -= 1
print('Yes' if reduce(lambda x, y: x <= y, H) else 'No')

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

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

print('Yes' if all(H[i-1] <= H[i] for i in range(1, n)) else 'No')

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

H[0] -= 1
for i in range(1, n):
    if H[i] < H[i-1]:
        H[i] -= 1
print('Yes' if all(h0 <= h1 for h0, h1 in zip(H, H[1:])) else 'No')

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

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

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

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

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

flg = True
h0 = H[0]-1
for h in H[1:]:
    flg &= h0 <= h
    h0 = h
if flg:
    print('Yes')
else:
    print('No')

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

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

flg = True
h0 = H[0]
for h in H[1:]:
    flg &= h0 <= h
    h0 = h
if flg:
    print('Yes')
else:
    print('No')

n = int(input())
H = list(map(int, input().split()))
 
H[0] -= 1
for i in range(1, n):
    if H[i-1] < H[i]:
        H[i] -= 1
print('Yes' if all(h0 <= h1 for h0, h1 in zip(H, H[1:])) else 'No')

Verdicts: Runtime Error

Wrong Answer

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

input = sys.stdin.readline

N = int(input().strip())
Hs = list(map(int, input().strip().split(' ')))

current_max = 1
for i in range(N - 1):
    former = Hs[i]
    latter = Hs[i + 1]
    if former > latter and former > current_max:
        Hs[i] -= 1
    current_max = max(Hs[i], Hs[i+1])

    if Hs[i] > Hs[i+1]:
        print('No')
        sys.exit(0)
print('Yes')

import sys

input = sys.stdin.readline

N = int(input().strip())
Hs = list(map(int, input().strip().split(' ')))

current_max = 0
for i in range(N - 1):
    if Hs[i] > current_max:
        Hs[i] -= 1
        current_max = Hs[i]

    if Hs[i] > Hs[i+1]:
        print('No')
        sys.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())
h = [int(x) for x in input().split()]

ans = True
for i in range(n-1):
  dis = h[i] - h[i+1]
  if dis >= 1:
    continue
  elif dis == 0:
    h[i+1] -= 1
    continue
  else:
    ans = False
    break

if ans:
  print('Yes')
else:
  print('No')
  


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

ans = True
for i in range(n-1):
  dis = h[i] - h[i+1]
  if dis >= 0:
    continue
  elif dis == -1:
    h[i+1] -= 1
    continue
  else:
    ans = False
    break

if ans:
  print('Yes')
else:
  print('No')
  


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

ans = True
for i in range(n-1, 0, -1):
  dis = h[i] - h[i-1]
  if dis >= 0:
    continue
  elif dis == -1:
    h[i-1] -= 1
    continue
  else:
    ans = False
    break

if ans:
  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())
h = [int(i) for i in input().split()] # input:"1 2 3 4 5"
ans = 0
for i in range(n-1):
  if min(h)+1<h[i]:
    ans = 1
    break
  else:
    if min(h)+1==h[i]:
      h[i]-=1
if sorted(h)==h:
  print('Yes')
else:
  print('No')
if ans == 1:
  print('No')
elif sorted(h)==h:
  print('Yes')
else:
  print('No')

n = int(input())
h = [int(i) for i in input().split()] # input:"1 2 3 4 5"



ans = 'Yes'
for i in range(n-1):
  if h[i]>h[i+1]+1:
    ans = 'No'
    break
  elif h[i]==h[i+1]+1:
    h[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):
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1

    elif 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):
    print(h)
    if h[i] < h[i+1]:
        h[i+1] -= 1

    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

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

    elif h[i] > h[i+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())
li = list(map(int,input().split()))
out_count = 0


for j in range(N - 1 , 0 , -1):
  if li[j] >= li[j - 1] + 2:
    out_count += 1
  elif li[j] == li[j - 1] + 1:
    li[j - 1] -= 1

if li[0] > li[1] + 1:
  out_count += 1
    
if out_count == 0:
  print('Yes')
else:
  print('No')

N = int(input())
li = list(map(int,input().split()))
out_count = 0


for j in range(N - 1 , 0 , -1):
  if li[j] >= li[j - 1] + 2:
    out_count += 1
  elif li[j] == li[j - 1] + 1:
    li[j - 1] -= 1

if li[0] > li[1]:
  out_count += 1
    
if out_count == 0:
  print('Yes')
else:
  print('No')

N = int(input())
li = list(map(int,input().split()))
out_count = 0
if li[0] > li[1] + 1:
  out_count += 1

for j in range(N - 1 , 0 , -1):
  if li[j] >= li[j - 1] + 2:
    out_count += 1
  elif li[j] == li[j - 1] + 1:
    li[j - 1] -= 1


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

N = int(input())
li = list(map(int,input().split()))
out_count = 0


for j in range(N - 1 , 0 , -1):
  if li[j] >= li[j - 1] + 2:
    out_count += 1
  elif li[j] == li[j - 1] + 1:
    li[j - 1] -= 1
if li[0] > li[1]:
  out_count += 1
    
if out_count == 0:
  print('Yes')
else:
  print('No')

N = int(input())
li = list(map(int,input().split()))
out_count = 0


for j in range(N - 1 , 0 , -1):
  if li[j] >= li[j - 1] + 2:
    out_count += 1
  elif li[j] == li[j - 1] + 1:
    li[j - 1] -= 1
if out_count == 0:
  print('Yes')
else:
  print('No')

N = int(input())
li = list(map(int,input().split()))
out_count = 0


for j in range(N - 1 , 0 , -1):
  if li[j] >= li[j - 1] + 2:
    out_count += 1
  elif li[j] == li[j - 1] + 1:
    li[j - 1] -= 1
if li[0] > li[1]:
  out_count += 1
    
if out_count == 0:
  print('Yes')
else:
  print('No')

N = int(input())
li = list(map(int,input().split()))
out_count = 0

for j in range(N - 1 , 0 , -1):
  if li[j] <= li[j - 1] - 2:
    out_count += 1
  elif li[j] == li[j - 1] - 1:
    li[j - 1] -= 1
if out_count == 0:
  print('Yes')
else:
  print('No')

Verdicts: Runtime Error

Runtime Error

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

prev = H[0]
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]
    continue
  print('No')
  return
print('Yes')


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

prev = H[0]
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]:
    continue
  print('No')
  return
print('Yes')


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

prev = H[0]
r = True
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]:
    continue
  r = False
  break

if r:
  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):
print("Yes")

n = int(input())
h = list(map(int, input().split()))
h[0]-=1
for i in range(n-1):
    if h[i] > h[i+1]:
        h[i] = h[i]-1

if all(h[i] <= h[i+1] for i in range(n-1)):
        print("Yes")
        exit()
print("No")

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


result = "Yes"

for i in range(1, N):
    if H[i] == H[i - 1] + 1:
        H[i] -= 1
    elif H[i] == H[i - 1]:
        continue
    else:
        result = "No"
print(result)

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

result = "Yes"


for i in range(1, N)[::-1]:
    if H[i - 1] <= H[i]:
        continue
    elif H[i - 1] - H[i] == 1:
        H[i - 1] -= 1
    else:
        result = "No"

print(result)

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):
    if h[i+1] == h[i] - 1:
        h[i] = h[i] - 1
flag = True
for i in range(n):
    if h[i+1] < h[i]:
        flag = False
        break
if flag == True:
    print('Yes')
else:
    print('No')

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

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

import sys
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.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())
Hs = list(map(int, input().split()))

prev = Hs[0]
flag = True
for i in range(1,len(Hs)):
    if Hs[i] <prev:
	flag = False
	break
    elif Hs[i] == prev:
	prev = Hs[i]
    else:
	prev = Hs[i]-1
if flag:
    print("Yes")
else:
    print("No")



N = int(input())
Hs = list(map(int, input().split()))
 
prev = Hs[0]
flag = True
for i in range(1,len(Hs)):
    if Hs[i] <prev:
      flag = False
      break
    elif Hs[i] == prev:
      prev = Hs[i]
    else:
      prev = Hs[i]-1
if flag:
    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()]
h.reverse()

flag = True

for i in range(1, n):
    print(h, i)

    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

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


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

flag = True

for i in range(1, n):
    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

print('Yes') if flag 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()))
isYes = True
tmpmin = 10**9+1
for i in range(1, n):
    if h[n-(i+1)] < tmpmin:
        tmpmin = h[n-(i+1)]
    if h[n-i] - h[n-(i+1)] >= 2 or h[n-i] - tmpmin >=2:
        isYes = False
        break
if isYes:
    print('Yes')
else:
    print('No')

n = int(input())
h = list(map(int, input().split()))
isYes = True
tmpmin = 10**9+1
for i in range(1, n):
    if h[n-i] <= tmpmin:
        tmpmin = h[n-i]
    if h[n-(i+1)]-h[n-i]>= 2 or h[n-(i+1)]-tmpmin >= 2:
        isYes = False
        break
if isYes:
    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()) 
c=list(map(int, input().split()))
ans = 0

if n == 1:
    print('Yes')
    exit()
if n >= 2:
    for i in range(n-1):
        if c[i] > c[i+1] +1:
            print('No')
            exit()
        if c[i] == c[i+1] +1:
            ans = max(ans,c[i])
            if c[i+1] < ans:
                print('No')
                exit()


print('Yes')

n=int(input()) 
c=list(map(int, input().split())) 
ans = 0
 
if n == 1:
    print('Yes')
    exit()
if n == 2:
    if c[0] > c[1] + 1:
        print('No')
        exit()
if n >= 3:
    for i in range(n-1):
        if c[i] > c[i+1] +1:
            print('No')
            exit()
        if c[i] == c[i+1] +1:
            ans = max(ans,c[i])
            if c[i+1] + 1 < ans:
                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()))
lenH = len(H)
for i in range(lenH-1):
  h_2 = H[lenH-i]
  h_1 = H[lenH-i-1]
  if h_2 < h_1:
    if h_1 - h_2 > 1:
      print('No')
      break
    else:
	  H[lenH-i-1] -= 1
print('Yes')

N = int(input())
H = list(map(int, input().split()))
lenH = len(H)
if lenH <= 1:
  print('Yes')
  exit()
for i in range(lenH-1):
  h_2 = H[lenH-i-1]
  h_1 = H[lenH-i-2]
  if h_2 < h_1:
    if h_1 - h_2 > 1:
      print('No')
      exit()
    else:
      H[lenH-i-2] -= 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_ls = list(map(int,input().split("")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)


N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)



import numpy as np
from scipy import signal

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

H = np.array(H)

H_dif = H[1:]-H[:-1]

if (H_dif <=-2).any() == True:
    ans = "No"
elif (H_dif >= 0).all() == True:
    ans = "Yes"

else:
    ans = 'Yes'
    min_ind = signal.argrelmin(H)[0]
    tmp_ind = 0
    for ind in min_ind:
        
        if H[tmp_ind:ind].max() > H[ind]+1:
            ans = 'No'
            break
        tmp_ind = ind

    if H[tmp_ind:ind].max() > H[-1]+1:
        ans = 'No'

print(ans)

N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)


N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

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):
N=int(input())
H=list(map(int,input().split()))
if N>1:
    for i in range(N-1):
        if H[i]<=H[i+1]-1:
            H[i+1]-=1
        if H[i]>H[i+1]:
            print('NO')
            exit()
    print('YES')
else:
    print('YES')

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

Verdicts: Wrong Answer

Accepted