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 bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
H = LI()



if N ==1:
    print('Yes')
    break
ans = True
for i in range(N-1):
    if H[i] <= H[i+1]:
        # print(i,'1')
        continue
    elif (not i==0) and H[i]-1 == H[i+1]:
        if not H[i-1] == H[i]:
            H[i] -= 1
            # print(i,'2')
            continue
    # print(i,'3')
    ans = False
    break

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

import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
H = LI()



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



# if N ==1:
#     print('Yes')
#     exit()
# ans = True

#     if H[i] <= H[i+1]:
#         # print(i,'1')
#         continue
#     elif (not i==0) and H[i]-1 == H[i+1]:
#         if not H[i-1] == H[i]:
#             H[i] -= 1
#             # print(i,'2')
#             continue
#     # print(i,'3')
#     ans = False
#     break

# if ans:
#     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()))
c = 0
for i in range(len(h)-1):
    if h[i+1]-h[i] >= 2:
        print("No")
        c += 1
        break
        
if c == 0:
    print("Yes")    
    

n = int(input())
h = list(map(int,input().split()))
c = 0
t = 0
for i in range(len(h)-2):
    if h[i+2]<h[i+1]<h[i] or h[i+1]-h[i] <= -2:
        print("No")
        c += 1
        break
    if h[i+1]<h[i]:
        t += 1
        if t == 2:
            print("No")
            c += 1
            break
    elif h[i+1]>h[i]:
        t = 0
    
            
if c == 0:
    if len(h)>=2:
        if h[-1]-h[-2] <= -2:
            print("No")
        else:
            print("Yes")
    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):
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    N = int(input())
    H = [int(a) for a in input().split()]
    # H = [
    #     int(input())
    #     for _ in range(N)
    # ]
    # A = [int(a) for a in input().split()]

    m = MAX
    for hi in reversed(H):
        if hi > m + 1:
            print("NO")
            return
        m = min(hi, m)
    print("YES")


if __name__ == '__main__':
    main()


from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    N = int(input())
    H = [int(a) for a in input().split()]
    # H = [
    #     int(input())
    #     for _ in range(N)
    # ]
    # A = [int(a) for a in input().split()]

    m = MAX
    for hi in reversed(H):
        if hi > m + 1:
            print("No")
            return
        m = min(hi, m)
    print("Yes")


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

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

Submission attempts (in order):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else

#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n), x(n);
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    bool ok = false;

    if (ok) {
        puts("POSSIBLE");
    } else {
        puts("IMPOSSIBLE");
    }
    return 0;
}

n = int(input())
h = list(map(int, input().split()))
mn = 0
ans = "Yes"
for i in h:
    if i <= mn - 2:
        ans = "No"
    else:
        mn = max(mn, i)
print(ans)


Verdicts: Runtime Error

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

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


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


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


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N = int(input())
H_list = list(map(int, input().split()))
ans = "Yes"
for i in range(1, N-1):
    if H_list[i]<H_list[i-1]:
        H_list[i]-=1
    if H_list[i]<H_list[i-1]:
        ans = "No"
        break
print(ans)

N = int(input())
H_list = list(map(int, input().split()))
ans = "Yes"
for i in range(1, N-1):
    if H_list[i]<H_list[i-1]:
        H_list[i]-=1
        if H_list[i]<H_list[i-1]:
            ans = "No"
            break
print(ans)

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import sys
N = 3
H = [3,3,2]


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


print("Yes")

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

if N==1:
    print("Yes")
    sys.exit()
else:
    for i in range(N-1):
        if H[i] < H[i+1]:
            H[i+1] = (H[i+1] - 1)
        if H[i] > H[i+1]:
            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):
def solve(N, H):

    if(N == 1):
        return 1
    
    else:

        highest = H[0]

        for i in range(1,N):

            if(highest - H[i] > 1):
                return 0

            else:
                if(highest < H[i]):
                    highest = H[i]
    
    return 1


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

if(solve(N,H) == 1):
    print('YES')
else:
    print('NO')

def solve(N, H):

    if(N == 1):
        return 1
    
    else:

        highest = H[0]

        for i in range(1,N):

            if(highest - H[i] > 1):
                return 0

            else:
                if(highest < H[i]):
                    highest = H[i]
    
    return 1


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

if(solve(N,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())
H = [int(i) for i in input().split()]
high = H[0]
for i in range(1,n):
    tmp = H[i]-high
    if 0<=tmp<=1:
        pass
    elif tmp = -1:
        high -= 1
    elif tmp > 1:
        high = H[i]
    else:
        print('No')
        exit()
print('Yes')


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


Verdicts: Runtime Error

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

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

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

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

if imp == 0:
    print(H,'Yes')
else:
    print(H,'No')

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

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

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

if imp == 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()))

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

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

# coding: utf-8
# Your code here!
N=int(input())

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

H.reverse()
#print(H)

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
x＝list(map(int, input().split()))
for i in range(n):
  if x[i]>x[i+1]:
    x[i]==x[i]-1
for j in range(n):
  if x[j]>x[j+1]:
    print("No")
    exit()
print("Yes")

n = int(input())
x＝list(map(int, input().split()))
y = []
for i in range(n):
  if x[i]>x[i+1]:
    y.append(x[i]-1)
  else:
    y.append(x[i])
for j in range(n):
  if y[j]>y[j+1]:
    print("No")
    exit()
print("Yes")

n = int(input())
x＝list(map(int, input().split()))
for i in range(n-1):
  if x[i]>x[i+1]:
    x[i]-=1
for j in range(n-1):
  if x[j]>x[j+1]:
    print("No")
    exit()
print("Yes")
  

n = int(input())
x＝[list(map(int,input().split()))]
y = []
for i in x:
  if x[i]>x[i+1]:
    y.append(x[i]-1)
  else:
    y.append(x[i])
for j in y:
  if y[j]>y[j+1]:
    print("No")
    exit()
print("Yes")

n = int(input())
x＝[list(map(int,input().split()))]
y = []
for i in range(n):
  if x[i]>x[i+1]:
    y.append(x[i]-1)
  else:
    y.append(x[i])
for j in range(n):
  if y[j]>y[j+1]:
    print("No")
    exit()
print("Yes")

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

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

n=int(input())
a=list(map(int,input().split()))
flag=0;maxi=0
for i in range(n):
  if a[i]>maxi:maxi=a[i]
  if maxi-a[i]>=2:
    flag=1
    break
if flag==1:print("Yes")
else:
  print("No")


n=int(input())
a=list(map(int,input().split()))
flag=0;maxi=0
for i in range(n):
  if a[i]>maxi:maxi=a[i]
  if maxi-a[i]>=2:
    flag=1
    break
if flag==1:print("No")
else:
  print("Yes")


Verdicts: Wrong Answer

Wrong Answer

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

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

p1=p2=0
for i in H:
   print(prv,i,i<prv-1,prv<=i, prv-1<=i)
   if i<max(p2,p1-1):
    #print('No')
    break
   if i<p1:
    p2=p1-1
   else:
    p2=p1
   p1=i
else:
    print('Yes')

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

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

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

print('Yes')

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

for i in range(1,n):
  if hs[i-1]==hs[i]:
    pass
  elif hs[i-1]-hs[i]>=1:
    print('No')
    exit()
  elif hs[i-1]-hs[i]<1:
      hs[i]-=1

print('Yes')

Verdicts: Wrong Answer

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

Submission attempts (in order):
n=int(input())
h=list(map(int,input().split()))
temp=0
if n==1:
  print("Yes")
else:
  for i in range(0,n-1):
    if h[i]-1<temp:
      print("No")
      break
    temp=max(temp,h[i])
  else:
    print("Yes")

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

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

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

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()
    tmp = -1
    for n in range(N):
        print(n)
        if tmp-1 <= H[n]:
            tmp = max(tmp, H[n])
        else:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()


import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()
    tmp = -1
    for n in range(N):
        if tmp-1 <= H[n]:
            tmp = max(tmp, H[n])
        else:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

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

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


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

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

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

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

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
h = list(map(int, input().split()))
coun = 10 ** 10
ans=0
for i in range(n-1):
    if len(h) == 1:
        print("YES")
    if h[i] - h[i + 1] >= 2:
        ans=1
    if h[i] - h[i + 1] == 1 and not(coun-h[i+1]==1):
        coun = h[i] - 1
    elif h[i] - h[i + 1] <= 0 :
        pass
    else:
        ans = 1
if ans == 1:
    print("NO")
else:
    print("YES")


n = int(input())
h = list(map(int, input().split()))
coun = 10 ** 10
ans=0
for i in range(n-1):
    if len(h) == 1:
        print("YES")
    if h[i] - h[i + 1] >= 2:
        ans=1
    if h[i] - h[i + 1] == 1 and not(coun-h[i+1]==1):
        coun = h[i] - 1
    elif h[i] - h[i + 1] <= 0 :
        pass
    else:
        ans = 1
if ans == 1:
    print("NO")
else:
    print("YES")


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

for k in range(N):
    H.append(input())
    
if N == 1:
    print("Yes")
    
else:
    for i in range(N - 1, -1, -1):
        if H[i] - H[i - 1] == -1:
            H[i - 1] -= 1
            
        elif H[i] - H[i - 1] < -1:
            print("No")
            break
            
    if k == 0:
        print("Yes")
        

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

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


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


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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
N = int(input())
H = list(map(int, input().split()))
ans = True
b = 999999
if ans == True:
  for i, x in enumerate(H[::-1]):
    if i != 0:
      if x <= b:
        b = x
      elif (x-1) <= b:
        b = x-1
      else:
        ans = False
        break
    else:
      b = x
print(ans)

import fractions
A, B, C, D = map(int, input().split())
CD = C * D // fractions.gcd(C,D)
def n_div(k):
  return B // k - (A-1) // k
ans = B - A + 1 - n_div(C) - n_div(D) + n_div(CD)
print(ans)

N = int(input())
H = list(map(int, input().split()))
ans = True
b = 999999
if ans == True:
  for i, x in enumerate(H[::-1]):
    if i != 0:
      if x <= b:
        b = x
      elif (x-1) <= b:
        b = x-1
      else:
        ans = False
        break
    else:
      b = x
if ans:
  print("Yes")
else:
  print("No")

Verdicts: Wrong Answer

Runtime Error

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

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

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

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

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


print("Yes")


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

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

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

for i in range(N-1):
	if Hs[i] <= Hs[i+1]:
		print("No")
		exit(0)


print("Yes")


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

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

for i in range(N-1, 1, -1):
	if Hs[i] - Hs[i-1] < -1:
		print("No")
		exit(0)
	if Hs[i] - Hs[i-1] < 0:
		Hs[i-1] -= 1

for i in range(N-1, 1, -1):
	if Hs[i-1] > Hs[i]:
		print("No")
		exit(0)

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

for i in range(N-1):
    if abs(H[i] - H[i+1]) > 1:
        print('No')
        exit()

print('Yes')

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


# Revision ver
H.insert(0, 0)

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

    if not H[i-1] <= H[i]:
        print('No')
        exit()

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
    elif H[i] == H[i+1]:
        if H[i]-1 >= H[i-1]:
            H[i] -= 1

print(H)

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

H[0] -= 1

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

print('Yes')

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N = int(input())
H = [int(x) for x in input().split()][::-1]
b = int(10e9) + 1
for h in H:
    if h >= b + 2:
        print('No')
        exit()
    b = min(h, b - 1)
print('Yes')


N = int(input())
H = [int(x) for x in input().split()][::-1]
before = int(10e9) + 1
for h in H:
    if h >= before + 2:
        print('No')
        exit()
    before = min(before, h)
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

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]
    
    
    
    
    # N = 10 ** 5
    # h = 10 ** 9
    # example:
    # 1 2 1 1 -> 1 1 1 1 -> Yes
    # 1 2 2 1 -> 1 2 1 1 -> No
    # 1 2 3 1 -> 1 2 2 1 -> No

    cnt = 0
    
    a = None
    b = H[0]
    for i in range(1, n):
        c = H[i]
        sa = c - b
        if sa < -1:
            cnt = 2
            break
        elif sa < 0:
            if a and a == b:
                print(a, b, c)
                cnt = 2
                break
            cnt += 1
        a = b
        b = c
        if cnt > 1:
            break
    print(cnt)
    print("Yes" if cnt <= 1 else "No")


if __name__ == "__main__":
    main()


import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]
    
    
    
    
    # N = 10 ** 5
    # h = 10 ** 9
    # example:
    # 1 2 1 1 -> 1 1 1 1 -> Yes
    # 1 2 2 1 -> 1 2 1 1 -> No
    # 1 2 3 1 -> 1 2 2 1 -> No
    # 1 100 1 1 -> 1 99 1 1 -> No
    #

    cnt = 0
    
    a = None
    b = H[0]
    for i in range(1, n + 1):
        c = H[i]
        sa = c - b
        if sa < -1:
            cnt = 2
            break
        elif sa < 0:
            if a and a == b:
                cnt = 2
                break
            cnt += 1
        a = b
        b = c
        if cnt > 1:
            break
    print("Yes" if cnt <= 1 else "No")


if __name__ == "__main__":
    main()


import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Runtime Error

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

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

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

Verdicts: Wrong Answer

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

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

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

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

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

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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

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

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

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


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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
h = list(map(int,input().split()))
res = 'Yes'
if n != 1:
    for i in range(1,n):
        if h[i]<h[i-1]:
            h[i] -= 1
        if h[i]<h[i-1]:
            res = 'No'
            break
print(res)

n = int(input())
h = list(map(int,input().split()))
th = h[0]
flag = 0
res = 'Yes'
if n != 1:
    for i in range(1,n):
        if h[i]<th:
            h[i] -= 1
        if h[i]<th:
            res = 'No'
            break
        th = h[i]

print(res)

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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    H = string_to_int(inputs[0])
    min_h = -1

    if len(H) == 1:
        return "Yes"

    not_operation_start = -1
    for i in range(len(H)-1):
        if H[i] - H[i+1] >= 2:
            return "No"
        elif H[i] - H[i+1] == 1:
            if not_operation_start == -1:
                if i - 1 >= 0:
                    if H[i] - H[i-1] >= 1:
                        H[i] -= 1
                    else:
                        return "No"
                else:
                    H[i] -= 1
            else:
                if not_operation_start - 1 >= 0:
                    if H[not_operation_start] - H[not_operation_start-1] >= 1:
                        H[i] -= 1
                    else:
                        return "No"
                else:
                    H[i] -= 1
            not_operation_start = -1
        else:
            if not_operation_start == -1:
                not_operation_start = i
    return "Yes"


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    inputs()
    ret = solve(inputs(1))
    print(ret)


import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    H = string_to_int(inputs[0])
    min_h = -1

    if len(H) == 1:
        return "Yes"

    not_operation_start = 0
    for i in range(len(H)-1):
        flg = True
        if H[i] - H[i+1] >= 2:
            return "No"
        elif H[i] - H[i+1] == 1:
            if i - 1 >= 0:
                if H[i] - H[i-1] >= 1:
                    flg = True
                else:
                    flg = False
            else:
                flg = True
            if flg is False and not_operation_start != -1:
                if not_operation_start - 1 >= 0:
                    # if H[not_operation_start] - H[not_operation_start-1] >= 1
                    flg = False
                    for j in range(not_operation_start, i+1):
                        if H[j] - H[j - 1] >= 1:
                            flg = True
                            break
                else:
                    flg = True
            if flg:
                H[i] -= 1
            else:
                return "No"
            not_operation_start = -1
        else:
            if not_operation_start == -1:
                not_operation_start = i
    return "Yes"


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


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(lambda x: int(x), input().split(' '))
flg = 0

for i in range(n):
    if i > 0:
        if h[i + 1] >= h[i]:
            pass
        else:
            if flg == 1:
                print('No')
                continue
            h[i] -= 1
            flg = 1

            if h[i + 1] >= h[i]:
                pass
            else:
                print('No')


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

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

print('Yes')

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

for i in reversed(range(n)):
    if i < n - 1:

        h[i] = int(h[i])
        h[i + 1] = int(h[i + 1])

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

result = 'Yes'

if H[0] >=1:
  H[0] -= -1

for i in range(N-1):
  diff = H[i+1] - H[i]
  if diff >= 1:
    H[i+1] -= 1
  elif diff = 0:
    pass
  elif diff < 0:
    result = 'No'
    break
print(result)

from heapq import heappop, heappush
import sys
input = sys.stdin.readline

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
def main():
    N = input()
    value = list(map(int, input().split()))
    if len(value) == 1:
        print("Yes")
        return
    for i in range(len(value)-1):
        ans = "Yes"
        if value[i] < value[i+1] or value[i]- 1 < value[i+1]:
            continue
        else:
            ans = "No"
            break
    print(ans)



if __name__ == "__main__":
    main()

def main():
    N = int(input())
    value = list(map(int, input().split()))
    if N == 1:
        print("Yes")
        return
    for i in range(N):
        ans = "Yes"
        if i == 0:
            value[i] -= 1
            continue
        if value[i-1] < value[i]:
            value[i] -= 1
        elif value[i-1] == value[i]:
            continue
        else:
            ans = "No"
            break
    print(ans)

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted