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):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
h = rl()
temp = 0
for i in h:
    if temp > i: 
        print('NO')
        exit()
    temp = i
else:
    print('YES')






import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
h = rl()
temp = 0
for i in h:
    if temp > i: 
        print('No')
        exit()
    temp = i
else:
    print('Yes')






import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
h = rl()
temp = 0
for i in h:
    if temp == i:
        continue
    elif temp < i:
        temp = i-1
        continue
    else:
        print('No')
        exit()
else:
    print('Yes')






Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N=int(input())
arr=list(map(int,input().split()))
ans=1
kari=1
for i in range(N-1):
    kari=max(kari,arr[i]-1)
    print(i,kari,ans)
    if kari>arr[i+1]:
        ans=0
        print(i,kari,ans)
        break


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


N=int(input())
arr=list(map(int,input().split()))
ans=1
kari=1
for i in range(N-1):
    kari=max(kari,arr[i]-1)
    
    if kari>arr[i+1]:
        ans=0
        
        break


    
if ans==0:
    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())
lis = list(map(int,input().split()))
lis[0]-=1

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

import sys
"""
for line in sys.stdin:
    A, B, C = map(int, line.split())
"""
N = int(input())
H = list(map(int, input().split()))

int_before = 1000000000
cnt_ok = 0
for h in H:
  if (int_before - h) < -1: 
    print('No')
    break
  
  else:
    cnt_ok += 1
    int_before = h


if cnt_ok == N:
	print('Yes')

n = int(input())
lis = list(map(int,input().split()))
lis[0]-=1

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = input()
h = [int(i) for i in input().sprit()]

max = 0
i = 0
y = 1
for i in range(n):
    if h[i] > max:
        max = h[i]
    elif h[i] < max-1:
        y = 0
    
if y==1:
    print("Yes")
else:
    print("No")


n = input()
h = [int(i) for i in input().sprit()]

max = 0
y = 1
for i in range(n):
    if h[i] > max:
        max = h[i]
    else if h[i] < max-1:
        y = 0
        break
    
if y:
    print("yes")
else:
    print("no")


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

max = 0
i = 0
y = 1
for i in range(n):
    if h[i] > max:
        max = h[i]
    elif h[i] < max-1:
        y = 0
    
if y==1:
    print("Yes")
else:
    print("No")


n = input()
h = [int(i) for i in input().sprit()]

max = 0
i = 0
y = 1
for i in range(n):
    if h[i] > max:
        max = h[i]
    else if h[i] < max-1:
        y = 0
        break
    
if y:
    print("yes")
else:
    print("no")


n = input()
h = [int(i) for i in input().sprit()]

max = 0

while 1:
    for i in range(n):
        if h[i] > max:
            max = h[i]
        else if h[i] < max+1:
            print("no")
            break
    print("yes")
    break


n = input()
h = [int(i) for i in input().sprit()]

max = 0
i = 0
y = 1
for i in range(n):
    if h[i] > max:
        max = h[i]
    elif h[i] < max-1:
        y = 0
        break
    
if y==1:
    print("Yes")
else:
    print("No")


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

max = 0
i = 0
y = 1
for i in range(int(n)):
    if h[i] > max:
        max = h[i]
    elif h[i] < max-1:
        y = 0
    
if y==1:
    print("Yes")
else:
    print("No")

    

Verdicts: Runtime Error

Runtime Error

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

lastHeight = 0
for idx in range(len(H)):
    if H[idx] < lastHeight:
        print("NO")
        break
    elif H[idx] == lastHeight:
        lastHeight = H[idx]
    else:
        lastHeight = H[idx] - 1
else:
    print("YES")


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

lastHeight = 0
for idx in range(len(H)):
    if H[idx] < lastHeight:
        print("No")
        break
    elif H[idx] == lastHeight:
        lastHeight = H[idx]
    else:
        lastHeight = H[idx] - 1
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(n-1):
    if h[i]>=h[i+1]:
        h[i]-=1
for i in range(n-1):
    if h[i]>h[i+1]:
        print("No")
        quit()
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
    print(h)
for i in range(n-1):
    if h[i]>h[i+1]:
        print("No")
        quit()
print("Yes")

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

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

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

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
H = MAP()

max = 0
for h in H:
	if h>= max:
		max=h
	if h<= max-1:
		print('No')
		sys.exit()
print('Yes')

import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
H = MAP()

max = 0
for h in H:
	if h >= max:
		max = h
		continue
	if h < max-1:
		#print(max, h)
		print('No')
		sys.exit()
print('Yes')

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
cnt = int(input())
lst = list(map(int, input().split()))
ans = "yes"
maxNum = max(lst)
maxIndex = lst.index(maxNum)

for i, val in enumerate(lst):
  if i == 0:
    continue
  if (val + 1) < maxNum and maxIndex < i:
    ans = "no"
  

    
    
print(ans)

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


for i in range(len(H) - 1):
  if H[i] < H[i+1]:
    H[i+1] -= 1
  elif 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())
h = [ int(_) for _ in input().split() ]

for i in range(0,h-1):
    if h[i] > h[i+1]:
        h[i] = h[i]-1
    print(h)   
        
for i in range(0,h-1):
    if h[j] > h[j+1]:
        print('No')
        exit()
        
print('Yes')

# ABC 136 C
n = int(input())
h = [ int(_) for _ in input().split() ]
flag = True

for i in range(len(h)-1, 0, -1):
    if h[i-1] > h[i] +1:
        h[i-1] = h[i-1]-1  
        
for j in range(0,len(h)-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        break
        
if flag == True:
    print('Yes')

n = int(input())
h = [ int(_) for _ in input().split() ]
flag = True

for i in range(len(h)-1, 0, -1):
    if h[i] == h[i+1] +1:
        h[i] = h[i]-1  
        
for j in range(0,len(h)-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        break
        
if flag == True:
    print('Yes')

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

flag = True
h_s = [ x-1 for x in h ]
h_sorted = sorted(h)

for i in range(0,h-1):
    if h[i] > h[i+1]:
        h[i] = h[i]-1
    print(h)   
        
for i in range(0,h-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        
if flag == True:
    print('Yes')

# ABC 136 C
n = int(input())
h = [ int(_) for _ in input().split() ]
flag = True

for i in range(len(h)-1, 0, -1):
    if h[i-1] == h[i] +1:
        h[i-1] = h[i-1]-1  
        
for j in range(0,len(h)-1):
    if h[j] > h[j+1]:
        print('No')
        flag = False
        break
        
if flag == True:
    print('Yes')

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = map(int, input().split())

i = N
while i > 0:
  if H[i-1] > H[i] + 1:
    print('No')
    break
  if H[i-1] == H[i] + 1:
    H[i-1] -= 1
  i -= 1
print('Yes')

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

i = N - 1
while i > 0:
  if H[i-1] > H[i] + 1:
    print('No')
    break
  if H[i-1] == H[i] + 1:
    H[i-1] -= 1
  i -= 1
if i==0:
  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()))
a=[[] for i in range(n)]
a[0]+=[h[0]]
for i in range(1,n):
  for j in range(len(a[i-1])):
    if h[i]-a[i-1][j]==0:
      if h[i] not in a[i]:
        a[i]+=[h[i]]
    if h[i]-a[i-1][j]==1:
      if h[i] not in a[i]:
        a[i]+=[h[i]]
      if h[i]-1 not in a[i]:
        a[i]+=[h[i]-1]
if len(a[n-1])>0:
  print("Yes")
else:
  print("No")

n=int(input())
h=list(map(int,input().split()))
a=[h[0],h[0]-1]
for i in range(1,n):
  b=[]
  for j in range(len(a)):
    if h[i]-a[j]==1:
      b+=[h[i],h[i]-1]
    elif h[i]-a[j]==0:
      b+=[h[i]]
  a=b[:]
if len(a)>0:
  print("Yes")
else:
  print("No")

n=int(input())
h=list(map(int,input().split()))
a=[[] for i in range(n)]
a[0]+=[h[0]]
for i in range(1,n):
  for j in range(len(a[i-1])):
    if h[i]-a[i-1][j]==0:
      if h[i] not in a[i]:
        a[i]+=[h[i]]
    if h[i]-a[i-1][j]>=1:
      if h[i] not in a[i]:
        a[i]+=[h[i]]
      if h[i]-1 not in a[i]:
        a[i]+=[h[i]-1]
if len(a[n-1])>0:
  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 = list(map(int, input().split()))
for i in reversed(range(n)):
    if i == 0:
        print("Yes")
    elif H - H[i - 1] == -1:
        H[i - 1] -= 1
    elif H[i] - H[i - 1] < -1:
        print("No")
        break
    else:
        continue

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

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):
import numpy as np
N = int(input())
H = np.array(list(map(int, input().split())))

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2

tmp = H[1:] - H[:-1]

ans_2 = all(tmp2 > -2)

print("Yes") if ans_1 & ans_2 else print("No")

import numpy as np

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

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2
ans_2 = all((H[1:] - H[:-1]) > -2)

print("Yes") if ans_1 & ans_2 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):
# -*- coding: utf-8 -*-
 
n = int(input())
h = list(map(int, input().split()))
m = h[0]
r = 'Yes'
for i in range(n-1):
    if h[i] > m:
      m = h[i]
    if h[i+1] < m + 1:
      r = 'No'
      break
    
print(r)

# -*- coding: utf-8 -*-

n = int(input())
h = input().split()
h.reverse()
for i in range(n):
  for j in range(i+1, n) 
    if h[j] > h[i] + 1:
      print('No')
      return
print('Yes')


# -*- coding: utf-8 -*-
 
n = int(input())
h = list(map(int, input().split()))
h.reverse()
limit = h[0]
r = 'Yes'
for i in range(n-1):
    if h[i] < limit:
      limit = h[i]
    if h[i+1] > limit + 1:
      r = 'No'
      break
    
print(r)

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

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

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

for i in range(N-1):
    if H[i+1] - (H[i]-1) > 1:
        print("No")
        break
print("Yes")

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
a = [input() for i in range(2)]
n = int(a[0])
h = list(map(int, a[1].split()))

str = "Yes"
c = 10**9
for i in range(n):
    if h[i] <= c:
        c = h[i]
    else:
        if (h[i]-1) == c:
            c = h[i]
        else:
            str = "No"

print(str)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    *nh, = map(int, read().split())
    n, h = nh[0], nh[1:]
    o = "Yes"
    for i in range(1, n):
        if h[i-1]<h[i]:
            h[i] -= 1
        if h[i-1]>h[i]:
            o = "No"
            break
    print(o)

if __name__ == "__main__":
    main()


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 = [int(x) for x in input().split()]

for i in range(n-1, -1, -1):
  if hs[i-1] <= hs[i]:
    continue
  elif hs[i-1] - 1 <= hs[i]:
    hs[i-1] = hs[i-1] - 1
    continue
  else:
    print("No")
    break
else:
  print("Yes")


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

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

for i in range(1, n):
  if hs[i-1] > hs[i]:
    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):
import sys

N = int(input())
H = input().split()
S = 0

for i in range(H.index(max(H))):
  if int(H[i]) - int(H[i + 1]) > 0:
    if int(H[i]) - int(H[i + 1]) > 1:
      print('No')
      exit()
    S.append(i)
for i in range(H.index(max(H)), N):
  if int(H[i]) - int(H[i + 1]) > 0:
    S += 1
    if int(H[i]) - int(H[i + 1]) > 1 or S == 2:
      print('No')
      exit()

import sys

N = int(input())
H = input().split()
S = 0
M = H.index(max(H))
for i in range(M):
  if int(H[i]) - int(H[i + 1]) > 0:
    if int(H[i]) - int(H[i + 1]) > 1:
      print('No')
      exit()
    S.append(i)
for j in range(M, N - 1):
  if int(H[M]) - int(H[j]) > 1:
    print('No')
print('Yes')

import sys
N = int(input())
H = input().split()
S = 0
for i in range(N):
  if int(H[i]) > S:
    S = int(H[i])
  elif S - int(H[i]) >= 2:
    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())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    print(h)
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = hi
print(ans)


n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = 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(map(int,input().split()))
maxim=h[-1]
h=h[::-1]
for i in range(n-1):
    if h[i]-maxim>=2:
        print('NO')
        exit()

    elif h[i+1]-h[i]==1:
        h[i+1]+=-1

    elif h[i]-maxim==1:
        h[i]+=-1
    elif h[i+1]-h[i]>=2:
        print('NO')
        exit()

print('YES')

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

n = int(input())
h = list(map(int, input().split()))
h = h[::-1]
count = 0
for i in range(1, n):
    if h[i]-h[i-1]==1:
        h[i]+=-1
    elif h[i]-h[i-1]>=2:
        print('NO')
        exit()
print('YES')

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = map(int, input().split())
H.append(1000000001)

max = H[0]
for i in range(N):
    if max >= H[i+1] + 2:
        print('No')
        break
    if max < H[i+1]:
        max = H[i+1]
        
else:
    print('Yes')
        

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

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

for i in range(n-1):
    if (h[i+1]-h[i] <= 1) and (h[i+2] >= h[i]):
        c += 1
    else:
        pass
if c == 1:
    print('Yes')
else:
    print('No')

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

for i in range(n-1):
    if h[i] <= h[i+1]-1:
        h[i+1] = h[i+1]-1
    elif h[i] == h[i+1]:
        continue
    else:
        c = 1
if c == 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()))
ans =True
i=0

ma=max(H)
num=H.index(ma)
for i in range(num,N):
    if ma-2 >= H[i]:
        ans = False
        


if ans or N==1:
    print("YES")
else:
    print("NO")
    

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

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


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


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

ma=max(H)
num=H.index(ma)
for i in range(num,N):
    if ma-2 >= H[i]:
        ans = False
        


if ans or N==1:
    print("YES")
else:
    print("NO")
    

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

ma=max(H)
num=H.index(ma)
for i in range(num,N):
    if ma-2 >= H[i]:
        ans = False
        


if ans or N==1:
    print("YES")
else:
    print("NO")
    

n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
flag = True
for i in range(n - 1):
    # print(i)
    if h[i] > h[i + 1]:
        flag = False
        break
    elif h[i] <= h[i + 1] - 1:
        h[i + 1] -= 1

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


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

ans = 1
for i in range(N-1):
    if H_[i+1] < H_[i]:
        ans = 0
if ans == 0:
    print("No")
else:
    print("Yse")

N = int(input())
H_ = list(map(int,input().split()))
for i in reversed(range(N-1)):
    if H_[i+1] < H_[i]:
        H_[i] = H_[i] -1

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

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

n=int(input())
h=list(map(int,input().split()))
if n==1:
  print("Yes")
else:
  min=0
  for i in range(n):
    if h[i]>min:
      min=h[i]-1
    if h[i]<min:
      print("No")
      break
  else:
      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 = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l > list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l - 1 > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  print(i, l)
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l - 1 > list[i + 1] and l < list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

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

flg = 'Yes'
for i, l in enumerate(list):
  if l <= list[i + 1] or l <= list[i + 1] - 1:
    flg = 'No'
    break

print(flg)

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg = 'Yes'
for i, l in enumerate(list):
  if l <= list[i + 1] or l <= list[i + 1] - 1:
    flg = 'No'
    break
 
print(flg)

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i == len(list): break
  if add: l = l - 1
  if l > list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l - 1 > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list): break
  if add: l = l - 1
  if l > list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l - 1 > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

N = int(input())
H = input().split()
list = [int(x) for x in H]
 
flg, add = 'Yes', False
for i, l in enumerate(list):
  if i + 1 == len(list):
    break
  if add: l = l + 1 
  if l - 1 > list[i + 1] and l < list[i + 1]:
    flg = 'No'
    break
  elif l - 1 == list[i + 1]:
    add = True
  elif l > list[i + 1]:
    flg = 'No'
    break
  else:
    add = False
 
print(flg)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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):
b = input()
h = [int(i) for i in input().split(" ")]
hh = [i - 1 for i in h]
n = hh[0]
for i in range(1, len(h)):
    if n <= hh[i]:
        n = hh[i]
    elif n <= h[i]:
        n = h[i]
    else:
        print("NO")
        break
else:
    print("YES")


b = input()
h = [int(i) for i in input().split(" ")]
hh = [i - 1 for i in h]
c = [h[0]-1]
for i in range(1, len(h)):
    if c[i - 1] <= hh[i]:
        c.append(hh[i])
    elif c[i - 1] <= h[i]:
        c.append(h[i])
    else:
        print("NO")
        break
else:
    print("YES")

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
N = int(input())
H = list(map(int,input().split()))

A = 0
list = []
for i in H:
    i = i - 1
    if A > i:
        list.append(i)

    A = i

print(list)

if not list:
    print("Yes")
elif list[0] == 0:
    print("Yes")
elif list:
    print("No")
else:
    print("Yes")

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

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

for j in range(n-1):
    if h[j] > h[j+1]:
        print('No')
        break
else:
    print('Yes')

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

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

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

print(H)

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

# -*- coding: utf-8 -*-
N = int(input())
H = [int(j) for j in input().split()]

flag = 1

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

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

if flag == 1:
    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):
def q3():
    N = int(input())
    H = [int(i) for i in input().split()]
    ans = 'Yes'
    if len(H) == 1:
        print(ans)
        return

    for i in range(1, len(H) - 1):
        if H[i-1] > H[i] > H[i+1]:
            ans = 'No'
            break
        elif H[i] - H[i-1] > 1 or H[i+1] - H[i] > 1:
            ans = 'No'
            break

    print(ans)


if __name__ == '__main__':
    q3()


def q3():
    N = int(input())
    H = [int(i) for i in input().split()]
    ans = 'Yes'
    if len(H) == 1:
        print(ans)
        return

    for i in range(len(H)):
        if i == 0:
            H[i] -= 1
        elif H[i-1] - H[i] < 0:
            H[i] -= 1
        elif H[i-1] - H[i] >= 1:
            ans = 'No'
            break

    print(ans)


if __name__ == '__main__':
    q3()


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()))
before=l[0];d=0
for i in range(n):
  if before-l[i]>1:print('No');exit()
  elif before-l[i]==1:
    if d:print("No");exit()
    else:d+=1
  else:before=l[i];d=0
print("Yes")

n=int(input())
l=list(map(int,input().split()))
before=l[0];d=0
for i in range(n):
  if before-l[i]>1:print('No');exit()
  elif before-l[i]==1:
    if d:print("No");exit()
    else:d+=1
  elif before-l[i]==0:continue
  else:before=l[i];d=0
print("Yes")

n=int(input())
l=list(map(int,input().split()))
before=l[0]
for i in l:
  if before-i>1:print('No');exit()
  elif before-i==1:
print("Yes")


n=int(input())
l=list(map(int,input().split()))
before=l[0];d=0
for i in range(n):
  if before-l[i]>1:print('No');exit()
  elif before-l[i]==1:
    if d:print("No");exit()
    else:d+=1
  elif before-l[i]==0:continue
  else:d=0
  before=l[i]
print("Yes")

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i.  For each square, you will perform either of the following operations once:    * Decrease the height of the square by 1.   * Do nothing.  Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

Submission attempts (in order):
n = int(input())
h = [int(x) for x in input().split()]
tmp = h[n-1]
for i in h[::-1]:
    print(tmp, i)
    if i <= tmp:
        tmp = i
    elif i-1 <= tmp:
        tmp = i-1
    else:
        print('No')
        exit()
print('Yes')


n = int(input())
h = [int(x) for x in input().split()]
tmp = h[n-1]
for i in h[::-1]:
    if i <= tmp:
        tmp = i
    elif i-1 <= tmp:
        tmp = i-1
    else:
        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())
lh = list(map(int,input().split()))

i = len(lh)-1
mi = lh[i]
while(i > 0): 
    print(lh[i-1] <= mi+1)
    if (lh[i-1] <= mi+1):
        mi = min(mi, lh[i-1])
        i -= 1
    else:
        print("No")
        exit()
    
print("Yes")
 

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

i = len(lh)-1
mi = lh[i]
while(i > 0): 
    print(mi)
    if (lh[i-1] <= mi+1):
        mi = min(mi, lh[i-1])
        i -= 1
    else:
        print("No")
        exit()
    
print("Yes")
 

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

i = len(lh)-1
mi = lh[i]
while(i > 0): 
    if (lh[i-1] <= mi+1):
        mi = min(mi, lh[i-1])
        i -= 1
    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):
import sys

if __name__ == "__main__":
    N = int(input())
    input_str = input()
    H_str = input_str.split(' ')
    H = []
    for str in H_str:
        H.append(int(str))

    for i in range(len(H) - 1):
        if i != len(H) - 2:
            if H[i + 1] - H[i] <= -2:
                print('No')
                sys.exit(0)
            elif H[i + 1] - H[i] == -1:
                H[i] -= 1
        else:
            if H[i + 1] - H[i] <= -2:
                print('No')
                sys.exit(0)
            if H[i + 2] - H[i + 1] <= -1:
                print('No')
                sys.exit(0)

    print('Yes')

import sys

if __name__ == "__main__":
    N = int(input())
    input_str = input()
    H_str = input_str.split(' ')
    H = []
    for str in H_str:
        H.append(int(str))

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

    print('Yes')

import sys

if __name__ == "__main__":
    N = int(input())
    input_str = input()
    H_str = input_str.split(' ')
    H = []
    for str in H_str:
        H.append(int(str))

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

    print('Yes')

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

for i in range(N - 2, -1, -1):
    if arr[i] > arr[i + 1]:
        arr[i] -= 1
        if arr[i] > arr[i + 1]:
            print('No')
            break
else:
    print('Yes')


Verdicts: 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())
box=list(map(int,input().split()))
number=box[-1]
if n==1:print("Yes")
else:
    for i in range(n-1,0,-1):
        print(i)
        if i!=0:
            if (box[i-1]-box[i])==1:
                box[i-1]=box[i-1]-1
    box[-1]=number
    if box==sorted(box):
        print("Yes")
    else:print("No")

n=int(input())
box=list(map(int,input().split()))
number=box[-1]
for i in range(n):
    if (box[i]-box[i-1])<=0:
        box[i-1]=box[i-1]-1
box[-1]=number
if box==sorted(box):
    print("Yes")
else:print("No")

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

Verdicts: 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())
a=[int(i) for i in input().split()]
r='Yes'
for i in range(n-1):
  if a[-2-i]-a[-1-i]>1:
    r='No'
    break
  elif a[-2-i]-a[-1-i]==1:
    a[-2-i]=a[-2-i]-1
print(a)    

n=int(input())
a=[int(i) for i in input().split()]
r='Yes'
for i in range(n-1):
  if a[-2-i]-a[-1-i]>1:
    r='No'
    break
  elif a[-2-i]-a[-1-i]==1:
    a[-2-i]=a[-2-i]-1
print(r)    

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())
a = list(int(i) for i in input().split())  

if len(a) == 1:
  print('Yes')
else:
  ans = 'No' if sum(np.diff(np.array(a)) > 1) > 0 else 'Yes'
  print(ans)

import numpy as np
n = int(input())
a = list(int(i) for i in input().split())  

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

import numpy as np

N = int(input())
H = np.array(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: Runtime Error

Accepted