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

import sys
n = int(input())
ls = list(map(int, input().split()))
maxNum = ls[0] -1
for i in range(1,n):
    if maxNum < ls[i]:
        maxNum = ls[i] - 1
        if maxNum < ls[i]:
            print("No")
            sys.exit()
print("Yes")

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

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

if flag:
	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())
# s=list(map(int, input().split()))

N=4
s=[1,3,1,2]

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


        
if s==sorted(s):
    print("Yes")
else:
    print("No")


# N=int(input())
# s=list(map(int, input().split()))

N=4
s=[2,1,1,3,3,4,5,6,6]

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


        
if s==sorted(s):
    print("Yes")
else:
    print("No")


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

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

if s==s.sort():
    print("Yes")
else:
    print("No")


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

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



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


        
if s==sorted(s):
    print("Yes")
else:
    print("No")


# N=int(input())
# s=list(map(int, input().split()))

N=4
s=[1,3,1,2]

for i in range(N-1):    
    if s[i]<s[i+1]:
        s[i+1]=s[i+1]-1
        print(i,s[i])


        
if s==sorted(s):
    print("Yes")
else:
    print("No")


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




for i in range(len(s)-2,-1,-1):    
    if s[i]>s[i+1]:
        s[i]=s[i]-1


        
if s==sorted(s):
    print("Yes")
else:
    print("No")


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

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

prev = -999
for i in range(N):
  if pre <= hh[i]-1:
    pre = hh[i]-1
  elif pre <= hh[i]:
    pre = hh[i]
  else:
    print('No')
    exit(0)
print('Yes')
exit(0)


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

print('Yes')
exit(0)

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

ans = max(cnt, ans)
print(ans)

if ans == len(H)-1:
    print("Yes")
else:
    print("No")

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

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

if cnt == len(H)-1:
    print("Yes")
else:
    print("No")

Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
Hs = [int(i) for i in input().split()]
print(Hs)

for i,H in enumerate(Hs):
    if i == N - 1:
        break

    if H > Hs[i+1]:
        H -= 1
        Hs[i] = H
    if H > Hs[i+1]:
        print('No')
        exit()
    if i == 0:
        continue
    if H < Hs[i-1]:
        print('No')
        exit()

print('Yes')


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

for i in range(N):
    decr = None
    if i+1 != N:
        if Hs[i] > Hs[i+1]:
            decr = True
            Hs[i] -= 1
        if Hs[i] > Hs[i+1]:
            print('No')
            exit()

    if i == 0:
        continue

    if Hs[i] < Hs[i-1]:
        if not decr:
            Hs[i] -= 1
    if Hs[i] > Hs[i-1] + 1:
        print('No')
        exit()
    if Hs[i] < Hs[i-1]:
        print('No')
        exit()

print('Yes')


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

for i in range(N):
    decr = None
    if i+1 != N:
        if Hs[i] > Hs[i+1]:
            decr = True
            Hs[i] -= 1
        if Hs[i] > Hs[i+1]:
            print('No')
            exit()

    if i == 0:
        continue

    if Hs[i] > Hs[i-1]:
        if not decr:
            Hs[i] -= 1
    if Hs[i] < Hs[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):
result = True
for i in range(n):
    
    if (i != (n-1)):
        if(h[i] > h[i+1]): 
            h[i] -= 1
    
    elif (i != 0):
        if(h[i] > h[i-1]): 
            h[i] -= 1
    
    if (i != 0):
        if(h[i] < h[i-1]):
            result = False
            break

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

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

result = True
for i in range(n):
    if n == 1:
        break
    
    pos = ""
    if (i == 0):
        if (h[i] > h[i+1]):
            h[i] -= 1
    elif (i == (n-1)):
        if (h[i] > h[i-1]):
            h[i] -= 1
    else:
        if (h[i] > h[i+1]) | (h[i] > h[i-1]):
            h[i] -= 1
    
    if (i != 0):
        if(h[i] < h[i-1]):
            result = False
            break

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

Verdicts: Runtime Error

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

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

n = int(input())
h = list(map(int, input().split()))
mi = h[-1]
for i in range(n - 2, -1, -1):
    if h[i] > mi + 1:
        print("No")
        exit()
    mi = min(mi, h[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 = [int(i) for i in input().split()]
if h[0] != 1:
    h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i] < h[i - 1]:
            h[i] -= 1
        elif h[i] > h[i - 1]:
            print('No')
            exit()
    print('Yes')


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


n = int(input())
h = [int(i) for i in input().split()]
check = []
if len(h) == 1:
    print('Yes')
else:
    for i in range(n):
        if h[i - 2] - h[i] > 2 & i - 2 < i:
            check.append(False)
        else:
            check.append(True)
    if len(set(check)) == 1:
        print('Yes')
    else:
        print('No')


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


n = int(input())
h = [int(i) for i in input().split()]
check = []
if len(h) == 1:
    print('Yes')
else:
    for i in range(2, n):
        if h[i - 2] - h[i] >= 2:
            check.append(False)
            # print(False)
        else:
            check.append(True)
            # print(True)
    print(set(check))
    if len(set(check)) == 1:
        print('Yes')
    else:
        print('No')


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


n = int(input())
h = [int(i) for i in input().split()]
check = []
if len(h) == 1:
    print('Yes')
else:
    for i in range(n):
        if h[i - 2] - h[i] > 2 & i - 2 < i:
            check.append(False)
        else:
            check.append(True)
            print(True)
    if len(set(check)) == 1:
        print('Yes')
    else:
        print("No")


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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

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

Submission attempts (in order):
# -*- coding: utf-8 -*-

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

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

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

for i in range(N-1):
    if H[i+1]- H[i] < 0 :
        output = "No"
        break

print(output)

if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split()))

    tmp = 0

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

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

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

    print('Yes')


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

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

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

if max(H) - min(H) == 1:
    print("Yes")
    exit()

for i in range(0,N-2):
    if H[i+1] - H[i] >= 0 and H[i+2] - H[i+1] >= 0:
        continue
    else:
        H[i+1] = H[i+1] + 1
        if H[i+1] - H[i] >= 0 and H[i+2] - H[i+1] >= 0:
            continue
        else:
            output = "No"
            break

print(output)

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

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

output = "YES"
if N == 1:
    print("YES")
    exit()
elif N == 2:
    if H[1] - H[0] >= -1:
        print("YES")
        exit()
    else:
        print("NO")
        exit()

for i in range(N-2):
    if H[i+1] - H[i] >= 0 and H[i+2] - H[i+1] >= 0:
        continue
    else:
        H[i+1] = H[i+1] - 1
        if H[i+1] - H[i] >= 0 and H[i+2] - H[i+1] >= 0:
            continue
        else:
            output = "NO"
            break

print(output)

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

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

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

pre = -1
for i in range(N):
    if pre <= H[i] -1:
        pre = H[i] - 1
    elif pre <= H[i]:
        pre = H[i]
    else:
        output = "No"
        break

print(output)


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

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

H_rev = list(reversed(H))

ans = 'YES'
for i in range(N-1):
  if H_rev[i] < H_rev[i+1]:
    H_rev[i+1] -= 1

  if H_rev[i] < H_rev[i+1]:
    ans = 'NO'
    break

print(ans)

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

ans = 'Yes'

if N > 1:
  H_rev = list(reversed(H))

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

    if H_rev[i] < H_rev[i+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):
n=int(input())
base=0
for i in range(n):
    h=int(input())
    if base>h:
        ans="No"
        break
    base=max(base,h-1)
else:
    ans="Yes"
print(ans)

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






n = int(input())
h = [int(e) for e in input().split()]
flg = "Yes"
for i in range(n-1):
    h[i] -= 1
    if h[i+1] <= h[i]:
        flg = "No"
        break
print(flg)






n = int(input())
h = [int(e) for e in input().split()]
flg = "Yes"
equal = 0
for i in range(n-1):
    if equal:
        if h[i] > h[i+1]:
            flg = "No"
            break
        elif h[i] != h[i+1]:
            equal = 0


    else:
        h[i] -= 1
   
        if h[i+1] < h[i]:
            flg = "No"
            break
        elif h[i+1] == h[i]:
            equal = 1

        else:
            equal = 0
print(flg)






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 = True
if N == 1:
    pass
else:
    for i in range(N-2,-1,-1):
        if (H[i] - H[i+1]) >= 2:
            ANS = False
            break
        elif (H[i] - H[i+1]) == 1:
            H[i] -= 1

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

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

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

N = int(input())
H = list(map(int,input().split()))
ANS = True
if N == 1:
    pass
else:
    for i in range(N-2,-1,-1):
        if (H[i] - H[i+1]) >= 2:
            ANS = False
            break
        elif (H[i] - H[i+1]) == 1:
            H[i] -= 1

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

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

n=int(input())
h=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')
        return
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: 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:
  print("Yes")
  exit()
for i in range(N-1):
  if H[i]-1<=H[i+1]:
    H[i]-=1
  elif H[i]==H[i+1]:
    continue
  else:
    print("No")
    exit()
for i in range(N-1):
  if H[i]>H[i+1]:
    print("No")
    exit()
print("Yes")

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

N=int(input())
H=list(map(int,input().split()))
if N==1:
  print("Yes")
  exit()
if H[0]<H[1]:
  H[0]-=1
elif H[0]>H[1]:
  print("No")
  exit()
for i in range(1,N):
  if H[i-1]<H[i]:
    H[i]-=1
  elif H[i-1]>H[i]:
    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):
from decimal import Decimal, ROUND_HALF_UP
s = input()

rl_list = []
ans = ['0']
for i in range(len(s)-1):
  ans.append('0')
  if s[i] + s[i+1] == 'RL':
    rl_list.append(i)

before = 0
for i, rl in enumerate(rl_list):
  r_num = s[before: rl+1].count('R')
  before = rl + 1
  try:
    l_num = s[rl+1: rl_list[i+1]].count('L')
  except:
    l_num = s[rl+1: len(s)].count('L')
  ans[rl] = str(int(Decimal(r_num / 2).quantize(Decimal('0'), rounding=ROUND_HALF_UP)) + int(l_num / 2))
  ans[rl + 1] = str(int(r_num / 2) + int(Decimal(l_num / 2).quantize(Decimal('0'), rounding=ROUND_HALF_UP)))

print(' '.join(ans))


import sys

n = int(input())

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

max_ = 1

for i in range(n-1):
  max_ = max(h_list[i], max_)
  d = h_list[i+1] - h_list[i]
  if d < -1:
    print('No')
    sys.exit()
  elif i > 0:
    if max_ - h_list[i+1] > 1:
      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):
if h[-2] - h[-1] >1:
    print("No")

else:
    for i in range(1,n-1):
        l = h[-(2+i)]
        r = h[-(1+i)]
        if l - r < -1:
            print("No")
            break
    else:
        print("Yes")

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys
N = int(input())
boxes = list(map(int,input().split()))
prev = 0
for box in boxes[::-1]:
    if prev - box > -1:
        prev = box
    elif prev - box == -1:
        prev = box -1
    else:
        print("No")
        sys.exit()
print("Yes")

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

if sum(boxes) % N == 0:
    print("Yes")
    exit()
print("No")

import sys
N = int(input())
boxes = list(map(int,input().split()))
prev = 10**9+1
for box in boxes[::-1]:
    if prev - box > -1:
        prev = box
    elif prev - box == -1:
        prev = box -1
    else:
        print("No")
        sys.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())
l=list(map(int,input().split()))

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

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

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

a=int(input())
b=list(map(int,input().split()))
c=0
for i in b:
    if c>i:
        print("No")
        exit()
    elif c<i:
        c=i-1
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):
s = input()
pairs = []
r_count = 0
l_count = 0
prev = ''

for i in range(len(s)):
    if i == len(s) - 1:
        pair = [r_count, l_count + 1]
        pairs.append(pair)

    if prev == 'L' and s[i] == 'R':
        pair = [r_count, l_count]
        pairs.append(pair)
        r_count = 0
        l_count = 0

    if s[i] == 'R':
        r_count += 1
        prev = 'R'
    if s[i] == 'L':
        l_count += 1
        prev = 'L'

res = []
for pair in pairs:
    R = pair[0]
    L = pair[1]
    if (R % 2 == 0 and L % 2 == 0)\
        or (R % 2 == 1 and L % 2 == 1):
        res += [0 for i in range(R - 1)]
        res.append((R + L) // 2)
        res.append((R + L) // 2)
        res += [0 for i in range(L - 1)]
    else:
        if R % 2 == 0:
            res += [0 for i in range(R - 1)]
            res.append((R + L) // 2)
            res.append(((R + L) // 2) + 1)
            res += [0 for i in range(L - 1)]
        else:
            res += [0 for i in range(R - 1)]
            res.append(((R + L) // 2) + 1)
            res.append((R + L) // 2)
            res += [0 for i in range(L - 1)]

print(' '.join(map(str, res)))

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

res = 'Yes'

nums[0] -= 1
for i in range(N - 1):
    diff = nums[i + 1] - nums[i]
    if diff == 0:
        continue
    if diff >= 0:
        nums[i + 1] -= 1
    if diff < 0:
        res = 'No'
        break

print(res)

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
stair = input().split(' ')
flag = 0

for i in range(0, n - 1):
  if (int(stair[i]) == int(stair[i+1])):
    if (int(stair[i]) <= int(stair[i+1]) - 1):
      flag = 1
    else:
      flag = 0
      break;

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

n = int(input())
stair = input().split(' ')

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

  if (int(stair[i]) > int(stair[i+1])):
    print("No")
    exit()
print("Yes")



Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
arr = list(map(int, input().split()))
for i in range(n, 1, -1):
  if(arr[i-1] <= arr[i]):
    a = 1
  else:
    if(arr[i-1] - 1 > arr[i]):
      print("No")
      exit()
    else:
      arr[i-1] = arr[i - 1] - 1
if(sorted(arr) == arr):
  print("Yes")
else:
  print("No")

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

Verdicts: Runtime Error

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

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

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

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


for i in reversed(range(1,N)):
    ref = H[i] - H[i-1]
    if ref < -1:
        print("No")
        exit()
    elif ref == -1:
        H[i-1] -= 1

print("Yes")

Verdicts: Wrong Answer

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

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
H  = [int(i) for i in input().split()]
H1 = sorted(H)
ANS = H1[::-1]
ans = 'Yes'
for i in range(n-1):
    if(ANS[i] <= ANS[i+1]):
      ans = 'Yes'
    else:
      ans = 'No'
      break
print(ans)

n = int(input())
H  = [int(i) for i in input().split()]
ans = 'Yes'
for i in range(n-1):
    if(H[i] <= H[i+1] or H[i] <= H[i+1] -1):
      ans = 'Yes'
    else:
      ans = 'No'
      break
print(ans)

n = int(input())
H = list(map(int, input().split()))
M = H[0] - 1
for i in range(n):
    M = max(M, H[i] - 1)
    if H[i] < M:
        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())
stairs = list(map(int,input().split()))
min = stairs[0]


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

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


n = int(input())
stairs = list(map(int,input().split()))
min = stairs[0]


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

for i in range(n-1):
    if stairs[i+1] < stairs[i]:
        if stairs[i] -1 == stairs[i+1] and min < stairs[i] - 1:
            stairs[i] = stairs[i] - 1
        else:
            print('No')
            exit()
    min = stairs[i]
print('Yes')


n = int(input())
stairs = list(map(int,input().split()))
min = stairs[0]


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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

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

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

ans = 0

if n == 1:
	print('Yes')

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

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

check = 0

if n == 1:
	print('Yes')

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

Verdicts: Wrong Answer

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

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

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


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

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


Verdicts: Wrong Answer

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

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

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


if h == sorted(h):
  print('Yes')
else:
  print('No')

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

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

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

minnum = h[n-1]
for i in range(n-1,0,-1):
  if h[i-1]<=minnum:
    minnum = min(minnum,h[i-1])
  elif h[i-1]-1<=minnum:
    minnum = min(minnum,h[i-1]-1)
  else:
    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,*h=map(int,open(0).read().split())
for i in range(n-1)[::-1]:
  if h[i+1]<h[i]:
    h[i]-=1
    if h[i+1]<h[i]:
      print('NO')
      exit()
print('YES')

n,*h=map(int,open(0).read().split())
for i in range(n-1)[::-1]:
  if h[i+1]<h[i]:
    h[i]-=1
    if h[i+1]<h[i]:
      print('No')
      exit()
print('Yes')

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
h = [int(x) for x in input().split()]
ans = "Yes"

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

print(ans)


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

c = h[0]

for i in h:
    if c <= i:
        c = i

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

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

Verdicts: Wrong Answer

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

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


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

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

print("Yes")

Verdicts: Runtime Error

Wrong Answer

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

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

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

print(correct)
        

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

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

print(correct)
        

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 collections import Counter
a = int(input())
num_list = list(map(int,input().split()))
flag = "ok"
num_o = 0
for i in range(a-1):
  if num_list[i]-1 <= num_list[i+1] and num_list[i]-1 >= num_o:
    flag = "ok"
    num_o = num_list[i]
  else:
    flag = "ng"
num_counter = Counter(num_list)
num_most = num_counter.most_common()
if a == num_most[0][1] and a != 0:
  flag = "No"
if flag == "ok":
  print("Yes")
else:
  print("No")

a = int(input))
num_list = list(map(int,input().split()))
flag = ""
for i in range(a-1):
  if num_list[i]-1 <= num_list[i+1]:
    flag = "ok"
  else:
    flag = "ng"
if flag = "ok":
  print("Yes")
else:
  print("No")

a = int(input())
num_list = list(map(int,input().split()))
flag = ""
for i in range(a-1):
  if num_list[i]-1 <= num_list[i+1]:
    flag = "ok"
  else:
    flag = "ng"
if flag = "ok":
  print("Yes")
else:
  print("No")


from collections import Counter
a = int(input())
num_list = list(map(int,input().split()))
flag = "ok"
num_o = 0
for i in range(a-1):
  if num_list[i] > num_o:
    num_list[i] = num_list[i]-1
    num_o = num_list[i]
  if num_list[i]-num_list[i+1] > 0:
    flag = "ng"
    break

num_counter = Counter(num_list)
num_most = num_counter.most_common()
#if a == num_most[0][1] and a != 0:

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


Verdicts: 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):
# -*- coding: utf-8 -*-
n = int(input())
li = [map(int, input().split())]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)

# -*- coding: utf-8 -*-
n = int(input())
l = [int(i) for i in input().split()]
if n > 1:
  for j in range(n):
    if max(l[:j]) - min(l[j:]) >= 2:
      print('No')
      exit()
print('Yes')

# -*- coding: utf-8 -*-
n = int(input())
l = [int(input()) for i in range(n)]
if n > 1:
  for j in range(n):
    if max(l[:j]) - min(l[j:]) >= 2:
      print('No')
      exit()
print('Yes')

# -*- coding: utf-8 -*-
n = int(input())
li = [int(a) for a in input().split()]
ans = 'Yes'

if n > 1:
  for i in range(n-1):
    if li[-(i+2)] <= li[-(i+1)]:
      pass
    elif li[-(i+2)] - 1 <= li[-(i+1)]:
      li[-(i+2)] = li[-(i+2)] - 1
    else:
      ans = 'No'
      break

print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted