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):
a=input()
a=int(a)
b=[int(i) for i in input().split()]
x=0
c=0
border=0
for i in b:
    if x<=i-1 and border<=i:
        border=max(x,i-1)
        x=i
        continue
    c=1
    print("No")
    break
if c==0:
    print("Yes")


a=input()
a=int(a)
b=[int(i) for i in input().split()]
x=0
c=0
of=0
for i in b:
    if x<i:
        b[of]-=1
        of+=1
        x=i-1
        continue
    of+=1
    x=i
x=0
for i in b:
    if x>i:
        c=1
        print("No")
        break
    x=i
if c==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=list(map(int,input().split()))
ans='Yes'
a[0]-=1
for i in range(n-1):
  if a[i]>a[i+1]:
    ans='No'
  elif a[i+1]>a[i]:
    a[i+1]-=1
print(ans)

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

f = True

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

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

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

cur = H[0]

f = True
for hi in H[1:]:
  if cur <= hi:
    cur = hi
  elif cur <= hi + 1:
    cur = hi + 1
  else:
    f = False

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

Verdicts: Runtime Error

Runtime Error

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

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

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

print('Yes' if cnt == n-1 else 'No')


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

for i in reversed(range(0, n-1)):
    if H[i] > H[i+1]:
        H[i] -= 1
        if H[i] > H[i+1]:
            print('No')
            exit()

print('Yes')


Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
H_list = list(map(int,input().split()))
Flag = False
if N == 1:

    print("Yes")
    
else:
    for i in range(N):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            print("No")
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] = 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else
    
    Flag = True

if Flag = True:
    print("Yes")


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

if N != 1:
    for i in range(N-1):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            Flag = False
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] == 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else:
            continue
    
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):
s = input()+'R'
dp = [0] * (len(s))
rr = 0
ll = 0
for i in range(len(s) - 2):
    if (s[i] == 'R'): rr += 1
    else: ll += 1
    if (s[i] == 'R' and s[i + 1] == 'L'):
        l = i
        r = i+1
    if (s[i] == 'L' and s[i + 1] == 'R'):
        dp[l] = (ll+rr) // 2
        dp[r] = (ll + rr) // 2
        if (rr - ll) % 2 == 1 and rr > ll and rr % 2 == 0: dp[r] += 1
        if (rr - ll) % 2 == 1 and rr > ll and rr % 2 == 1: dp[l] += 1
        if (rr - ll) % 2 == 1 and rr < ll and ll % 2 == 1: dp[r] += 1
        if (rr - ll) % 2 == 1 and rr < ll and ll % 2 == 0: dp[l] += 1
        ll = 0
        rr = 0
print(*dp[:-1]) 

s = input()+'R'
dp = [0] * (len(s) + 1)
rr = 0
ll = 0
for i in range(len(s) - 2):
    if (s[i] == 'R'): rr += 1
    else: ll += 1
    if (s[i] == 'R' and s[i + 1] == 'L'):
        l = i
        r = i+1
    if (s[i] == 'L' and s[i + 1] == 'R'):
        dp[l] = (ll+rr) // 2
        dp[r] = (ll + rr) // 2
        if (rr - ll) % 2 == 1 and rr > ll and rr % 2 == 0: dp[r] += 1
        if (rr - ll) % 2 == 1 and rr > ll and rr % 2 == 1: dp[l] += 1
        if (rr - ll) % 2 == 1 and rr < ll and ll % 2 == 1: dp[r] += 1
        if (rr - ll) % 2 == 1 and rr < ll and ll % 2 == 0: dp[l] += 1
        ll = 0
        rr = 0
print(*dp[:-1]) 

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

Verdicts: Wrong Answer

Wrong Answer

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

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

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

    ans = "Yes"
    for i in range(2,len(h)):
        if not (h[i-2] <= h[i-1] and h[i-1] <= h[i]):
            if not (h[i-2] <= h[i-1]-1 and h[i-1]-1 <= h[i]):
                ans = "No"

    if len(h) == 2:
        if h[0]-1 > h[1]:
            ans = "No"
    
    if ans == "No": print(ans)
    else: print(ans)

if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(" ")))+[10**9]

    ans = "Yes"

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

result = True
for j in range(n-1):
  if hlist[j] <= hlist[j+1]:
    
  else if hlist[j]+1 == hlist[j+1]:
    
  else:
    result = False
    
if result:
  print('Yes')
else:
  print('No')

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

result = True
for j in range(n-1):
  if hlist[j] <= hlist[j+1]:
    pass
  elif hlist[j]+1 == hlist[j+1]:
    pass
  else:
    result = False
    
if result:
  print('Yes')
else:
  print('No')

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

result = True
for j in range(n-1):
  if hlist[j] < hlist[j+1]:
    hlist[j+1] -= 1
  elif hlist[j] == hlist[j+1]:
    pass
  else:
    result = False
    
if result:
  print('Yes')
else:
  print('No')

Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
n = int(input())
h = list(map(int,input().split()))

for i in range(n-1):
  if h[i] == h[i+1]+1:
    j = i
    p = 1
    break
  elif h[i] >= h[i+1] + 2:
    p = 2
    break
  else:
    j = 0
    p = 3

if j == 0:
  print("Yes")
else:  
  if min(h[j:]) + 2 <= h[j] or p == 2:
  print("No")
  else:
  print("Yes")

n = int(input())
h = list(map(int,input().split()))
d = [1]+[0]*(n-1)

for i in range(n-1):
  if h[i] >= 2+ h[i+1]:
    print('No')
    exit()
  if d[i] == 1 and h[i] <= h[i+1]:
    d[i+1] = 1
  elif d[i] == 0:
    if h[i] +1 <=h[i+1]:
      d[i+1] = 1
    elif h[i] -1 == h[i+1]:
      print('No')
      exit()
      
print('Yes')

Verdicts: Runtime Error

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

Submission attempts (in order):
N = int(input())
HList = list(map(int, input().split()))
last = 0
ans = True
for i in range(N):
    
    if last < HList[i]:
        HList[i] = HList[i] - 1
    
    if last > HList[i]:
        ans = False
        break
    last = HList[i]
print(HList)
print("Yes" if ans else "No")


N = int(input())
HList = list(map(int, input().split()))
last = 0
ans = True
for i in range(N):
    
    if last < HList[i]:
        HList[i] = HList[i] - 1
    
    if last > HList[i]:
        ans = False
        break
    last = HList[i]
print("Yes" if ans else "No")


Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
h = map(int, input().split())
ans = True
minv = 0

for i in range(len(h)-1):
    down = False
    
    if h[i] > h[i+1]:
        if h[i] - h[i+1] > 1:
            ans = False
            break
        else:
            if h[i]-1 >= minv:
                h[i] -= 1
                minv = h[i]
                down = True
            else:
                ans = False
                break
    if not down and  i!=0 and h[i-1] < h[i]:
        h[i] -= 1
        minv = h[i]


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

n = int(input())
h = list(map(int, input().split()))
ans = True
minv = 0

for i in range(len(h)-1):
    down = False
    
    if h[i] > h[i+1]:
        if h[i] - h[i+1] > 1:
            ans = False
            break
        else:
            if h[i]-1 >= minv:
                h[i] -= 1
                minv = h[i]
                down = True
            else:
                ans = False
                break
    if not down and  i!=0 and h[i-1] < h[i]:
        h[i] -= 1
        minv = h[i]


print("Yes") if ans 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())
l = list(map(int, input().split()))
s = 0
d = 0
for i in range(N-1):
  if l[i] - l[i+1] <= 1:
    s += 1
for i in range(N-2):
  if l[i] - l[i+2] <= 1:
    d += 1
if s == N-1 and d == N-2 or N ==1:
  print("YES")
else:
  print("NO")

N = int(input())
l = list(map(int, input().split()))
s = 0
d = 0
for i in range(N-1):
  if l[i] - l[i+1] <= 1:
    s += 1
for i in range(N-2):
  if l[i] - l[i+2] <= 1:
    d += 1
if (s == N-1 and d == N-2) or N ==1:
  print("YES")
else:
  print("NO")

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

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1
  else l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] == 1:
        d = 1
        break

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

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

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-2):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] <= -1:
        break
      if l[j] - l[j+1] == 0:
        continue
      if l[j] - l[j+1] == 1:
        d = 1
        break

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

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

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

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
    if (H[i] > H[i+1]):
        print('No')
        exit()
 
print('Yes')

Verdicts: Wrong Answer

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

Submission attempts (in order):
num = int(input())

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

befor = 0

f = True

for i in range(num):
  if h[i] > befor:
    befor = h[i] - 1
  elif h[i] <  befor:
    f = False:
      break
    
if f:
  print("Yes")
else:
  print("No")

num = int(input())

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

befor = 0

f = True

for i in range(num):
  if h[i] > befor:
    befor = h[i] - 1
  elif h[i] <  befor:
    f = False
    break
    
if f:
  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())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-i>1:
    print('No')
    return 0
print('Yes')


n=int(input())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-i>1:
    print('No')
    return
print('Yes')

n=int(input())
a=list(map(int,input().split()))
mx=0
for i in a:
  mx=max(mx, i)
  if mx-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())
h = list(map(int,input().split()))

falg = 0

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


n = int(input())
h = list(map(int,input().split()))
max_h = h[0]

falg = 0

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


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

falg = 0

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

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

if __name__ == "__main__":
    N = int(input())
    H = list(map(int, input().split()))  
    solve()



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

if __name__ == "__main__":
    N = int(input())
    H = list(map(int, input().split()))  
    solve()


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:
        print('No')
        exit()
print('Yes')


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

Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
li = list(map(int,input().split()))
li2 = []
key =[0] 
cnt = 0
flg = True
if N == 1:
    ans ="Yes"
    flg = False
while flg :
    cur1 = li[cnt]
    cur2 = li[cnt+1]
    sa = cur2 - cur1
    if key[cnt] == 0:
        if sa < -1:
            ans = "No"
            flg = False
        elif sa == -1:
            key.append(1)
        else:
            key.append(0)
    else:
        if sa < 0:
            ans = "No"
            flg = False
        else:
            key.append(0)
    if cnt == len(li)-1:
        ans = "Yes"
        flg = False
    cnt += 1
print(ans)

N = int(input())
li = list(map(int,input().split()))
li2 = []
key =[0] 
cnt = 0
flg = True
if N == 1:
    ans ="Yes"
    flg = False
while flg :
    cur1 = li[cnt]
    cur2 = li[cnt+1]
    sa = cur2 - cur1
    if key[cnt] == 0:
        if sa < -1:
            ans = "No"
            flg = False
        elif sa == -1:
            key.append(1)
            cnt += 1
        else:
            key.append(0)
            cnt += 1
    else:
        if sa < 0:
            ans = "No"
            flg = False
        elif sa == 0:
            key.append(1)
            cnt += 1
        else:
            key.append(0)
            cnt += 1
    if cnt == len(li)-1:
        ans = "Yes"
        flg = False
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()))

for i in reversed(range(1,n)):
    print(i)
    if h[i-1] - h[i] == 1:
        h[i-1] -= 1
    elif h[i-1] - h[i] >=2:
        print("No")
        exit()
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
sys.setrecursionlimit(10**6)

n = int(input())
h = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline

#ab = [[int(i) for i in readline().split()] for _ in range(n)]

fixed = [False]*n

for i in range(n-1):
    if h[i] < h[i+1]:
        continue
    elif h[i]-1 == h[i+1] and not fixed[i]:
        h[i] -= 1
        fixed[i+1] = True
        continue
    else:
        print('No')
        break
    break
else:
    print('Yes')

import sys
sys.setrecursionlimit(10**6)

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

fixed = [False]*n

for i in range(n-1):
    if h[i] < h[i+1]:
        h[i] -= 1
        h[i+1] -= 1
        fixed[i+1] = True
        continue
    elif h[i] == h[i+1]:
        fixed[i+1] = True
        continue
    else:
        print('No')
        break
    break
else:
    print('Yes')

Verdicts: Wrong Answer

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N = int(input())
H = list(map(int,input().split()))
lower_limit = 0
for h in H:
    if lower_limit > h:
        print('NO')
        break
    if h - 1 > lower_limit:
        lower_limit = h - 1
else:
    print('YES')


N = int(input())
H = list(map(int,input().split()))
lower_limit = 0
for h in H:
    if lower_limit > h:
        print('No')
        break
    if h - 1 > lower_limit:
        lower_limit = h - 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())
A = list(map(int,input().split()))
 


ans = 'Yes'
for i in range(N-1, 0, -1):
  print(i)
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

print(ans)

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

for i in range(N):
  if H[i-1] > H[i]: 
    ans = 'No'
    break
    
print(ans)

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

print(ans)

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



ans = 'Yes'
for i in range(N-1, 0, -1):
  if A[i] > A[i-1]: A[i-1] -= 1
  if A[i] > A[i-1]:
    ans = 'No'
    break

print(ans)

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


ans = 'Yes'
for i in range(N-1, 0, -1):
  print(i)
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

print(ans)
print(A)

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



ans = 'Yes'
for i in range(N-1, 0, -1):
  print(A[i], A[i-1])
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

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

print(ans)


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



ans = 'Yes'
for i in range(N-1, 0, -1):
  print(A[i], A[i-1])
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

print(ans)

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



ans = 'Yes'
for i in range(N-1, 0, -1):
  if A[i] < A[i-1]: A[i-1] -= 1
  if A[i] < A[i-1]:
    ans = 'No'
    break

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

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

Submission attempts (in order):
n = int(input())
h = list(map(int, input().split()))
# sv = h[n-1]
ok = True
for i in range(1, n):
    # if h[i] - sv + 1 >= 2:
        # ok = False
    if h[i] - h[i-1] < 0:
        ok = False
if ok:
    print('Yes')
else:
    print('No')

n = int(input())
h = list(map(int, input().split()))
# sv = h[n-1]
ok = True
for i in range(n-1)[::-1]:
    # if h[i] - sv + 1 >= 2:
        # ok = False
    if h[i] <= h[i+1]:
        continue
    elif h[i] == h[i+1] + 1:
        h[i] -= 1
    else:
        ok = False
    # if h[i] - h[i-1] < 0:
        # ok = False
if ok:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys
import random
n = int(input())
h = list(map(int,input().split()))

mx = h[0]
for i in range(1, n):
        
        if mx > h[i]+1:
                print('NO')
                break
        mx = max(mx,h[i+1])
print('Yes')

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

mx = h[0]
for i in range(1, n):
        
        if mx > h[i]+1:
                print('NO')
                break
        mx = max(mx,h[i+1])
else: print('Yes')

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

mx = h[0]
for i in range(1, n):
        
        if mx > h[i]+1:
                print('No')
                break
        mx = max(mx,h[i+1])
print('Yes')

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

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

cnt=0
cnt=H[0]
for i,num in enumerate(H):
    if(cnt>num):
        if(cnt>num+1):
            print("NO")
            cnt=-1
            break
    else:
        cnt=num

if(cnt!=-1):
    print("YES")
    

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

cnt=0
cnt=H[0]
for i,num in enumerate(H):
    if(cnt>H[i]):
        if(cnt>H[i]+1):
            print("NO")
            cnt=-1
            break
    else:
        cnt=H[i]

if(cnt!=-1):
    print("YES")
    

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

cnt=0
cnt=H[0]
for i,num in enumerate(H):
    if(cnt>num):
        if(cnt>num+1):
            print("No")
            cnt=-1
            break
    else:
        cnt=num

if(cnt!=-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):
#136c
N = int(input())
H_list = [int(e) for e in input().split()]

H_list[0] -= 1 

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

#136c
N = int(input())
H_list = [int(e) for e in input().split()]

H_list[0] -= 1 

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

Verdicts: Runtime Error

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

Submission attempts (in order):
n = int(input())
h = list(map(int,input().split()))

ans = "Yes"
for i in range(n-1):
    if h[i] - h[i + 1] >= 2:
        ans = "No"
        break;
    elif h[i] - h[i + 1] == 1:
        h[i] -= 1

for i in range(n-1):
    if h[i] > h[i + 1]:
        ans = "No" 

print(ans))

def main():
    n = int(input())
    h_list = list(map(int, input().split()))
    for i in range(n - 1)[::-1]:
        if h_list[i] == h_list[i + 1] + 1:
            h_list[i] = h_list[i] - 1
        elif h_list[i] > h_list[i + 1] + 1:
            print("No")
            return
    print("Yes")

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())
num = list(map(int, input().split()))
left = num[0]
for i in num:
  right = i
  if 0 < abs(right-left) <= 1:
    left = max(right, left)
  elif right-left == 0:
    left += 1
  else:
    print("No")
    exit()
print("Yes")

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

flg = False
ans = "Yes"
baseline = 0

for i in range(n - 1):
    d = h[i + 1] - max(h[i], baseline)
    if d < 0:
        if d == -1 and not flg:
            flg = True
        else:
            ans = "No"
    else:
        baseline = h[i + 1]
    
print(ans)

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

ans = "Yes"
now = 10 ** 9 + 1

for i in range(n - 1, -1, -1):
	for j in range(2):
		tmp = h_list[i] - j
		if tmp <= now:
			now = tmp
			break
		if j == 1:
		  ans = "No"
		
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np
N = int(input())
l = np.array(list(map(int,input().split())))
ans = 'Yes'
M = l[0]

for i in range(1,N):
    if l[i] > l[i-1]:
        M = l[i]
    print(M,l[i])

    if l[i]< M-1:
        ans ='No'
        break
print(ans)

import numpy as np
N = int(input())
l = np.array(list(map(int,input().split())))
ans = 'Yes'
M = l[0]

for i in range(1,N):
    if l[i] > l[i-1]:
        M = l[i]

    if l[i]< M-1:
        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):
from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

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

from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

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

Verdicts: Runtime Error

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

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

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

print(ans)

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

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

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

H = 0
ck = 0

for i in range(N):
  a = List[i]
  if a-1 >= H:
    H = a-1
  else:
    ck = 1
    
print("Yes" if ck == 0 else "No")

N = int(input())

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

H = 0
ck = 0

for i in range(N):
  a = List[i]
  if a >= H:
    if a-1 >= H:
      H = a -1
    else:
      H = a
  else:
    ck = 1

print("Yes" if ck == 0 else "No")


Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())

S=list(map(int,input().split()))
ans = True
print(S)
ma = max(S)
mi = min(S)

if ma - mi <= 1:
    print("Yes")

if S.index(ma) == N -1:
    print("Yes")
else:
    print("No")




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

ans = "Yes"
for i in range(1,n):
    if (Lists[i] - Lists[i-1]) > 1:
        ans = "No"
        break

print(ans)




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


ans = "Yes"
ma = -1
for i in range(n):
    if (ma < List[i]):
            ma = List[i] - 1
    elif (ma == List[i]):
        ma = List[i]
    else:
        ans = "No"
        break



print(ans)



Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N = int(input())
H = [int(_) for _ in input().split()]
YN = 0

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

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

if YN == 0:
    print('Yes')

else:
    print('No')

N = int(input())
H = [int(_) for _ in input().split()]
YN = 0

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

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

if YN == 0:
    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()))
count=0
for i in range(n-1):
    if h[i+1]-h[i]>=2:
        print("No")
        count+=1
        break
    elif h[i]-h[i+1]==1:
        h[i]-=1
    elif h[i+1]-h[i]==0:
        continue
if count==0:
    print("Yes")

n=int(input())
h=list(map(int,input().split()))
count=0
for i in h:
    if count>i:
        print("No")
        break
    count=max(count,i-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):
# -*- coding utf-8 -*-
N = int(input())
HN = [-1] + list(map(int, input().split()))

for i in range(1, N):
    if HN[i] > HN[i + 1]:
        if HN[i - 1] <= HN[i] - 1 and HN[i] - 1 <= HN[i + 1]:
            continue
        else:
            print('NO')
            exit()
print('YES')

# -*- coding utf-8 -*-
N = int(input())
HN = [-1] + list(map(int, input().split())) + [10 ** 10]

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
N,*H, = map(int,open(0).read().split())

def main():
    ihmax=0
    hmax=H[0]
    for i in range(1,N-1):
        if H[i-1]<=H[i]:
            ihmax=i-1
            hmax=max(H[i],hmax)       
        else:        
            if H[i-1]-1==H[i]:
                H[i-1]-=1
                if H[i-1]<hmax:
                    return 'No'
            else:
                return 'No'
    return 'Yes'
print(main())

N,*H=map(int,open(0).read().split())
H[0]-=1
def main():
    for i in range(1,N):
        if H[i-1]<H[i]:
            H[i]-=1
        elif H[i-1]==H[i]:
            continue
        else:
            return 'No'
    return 'Yes'
print(main())

Verdicts: Wrong Answer

Accepted