TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
if 1 not in a:
  print(-1)
else:
  x=1
  for i in range(n):
    if a[i]==x:
      x+=1
  print(n-x)

n=int(input())
a=list(map(int,input().split()))
if 1 not in a:
  print(-1)
else:
  x=1
  for i in range(n):
    if a[i]==x:
      x+=1
  print(n-x+1)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
a,b = map(int,input().split())
def fcd(a , b):
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return a*b//fcd(a , b)


print(lcm(a,b))


n = int(input())
num_list = list(map(int,input().split()))
cnt = 0
num = 1
for i in num_list:
    if i != num:
        cnt += 1
    else:
        num += 1

if num == 1:
    print(-1)
    
else:print(cnt)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
ori = [int(i) for i in input().split()]
print(N,ori)
count = ori.count(1)
print(count)
if count == 0:
    print(-1)
savepoint = 0
Break = 0
quit  = 0
for j in range(1,N+1):
    for i in range(savepoint+1,N):
        if ori[i] == j:
            Break = i
            savepoint = i
            #print(Break)
            #print(savepoint)
            #print(j,i)
            sub = j
            break
        #else: 
            
            #break
    
        #print(quit)
        #break
print(Break+1-sub)

N=int(input())
a=[int(i) for i in input().split()]
print(a)
if a.count(1)==0:
    print(-1)
else:
    ans=[]
    for i in range(N):
        if a[i]==len(ans)+1:
            ans.append(a[i])
    #print(N)
    #print(len(ans))
    print(N-len(ans)) 

N=int(input())
a=[int(i) for i in input().split()]
if a.count(1)==0:
    print(-1)
else:
    ans=[]
    for i in range(N):
        if a[i]==len(ans)+1:
            ans.append(a[i])
    #print(N)
    #print(len(ans))
    print(N-len(ans))  

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
for j in range(N):
    if searchNum ==1:
        if not searchNum in a:
            searchNum = N +1
            break
    if not j + 1 in a:
        searchNum -= 1
        break
    if j <= N: 
        if a[index + j] == searchNum:
            index = index + j
            searchNum += 1
            continue
    else: 
        continue

print(int(N -searchNum))



N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
for j in range(N+1):
    if searchNum ==1:
        if not searchNum in a:
            searchNum = N +1
            break
    if not searchNum in a[index + j:N-1]:
        searchNum -= 1
        break
    if j + index < N:
        if a[index + j] == searchNum:
            index = index + j
            searchNum += 1
            continue
    else:
        break

print(int(N -searchNum))



N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
for j in range(N+1):
    print(j)
    if searchNum ==1:
        if not searchNum in a:
            searchNum = N +1
            break
    if not searchNum in a[index:N]:
        searchNum -= 1
        break
    else:
        index = a.index(searchNum)
        searchNum += 1
        continue

print(int(N -searchNum))



N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
if not 1 in a:
    count = -1
else:
    for j in range(N):

        if a[j] ==searchNum:
            searchNum += 1
            continue
        else:
            count +=1
print(count)



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

k=1
cnt=0
for i in range(n):
  if A[i]!=k:
    cnt+=1
  else:
    k+=1
if cnt==n:
  print(-1)
else:
  print(-1)
    

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

k=1
cnt=0
for i in range(n):
  if A[i]!=k:
    cnt+=1
  else:
    k+=1
if cnt==n:
  print(-1)
else:
  print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())+1
a=list(map(int,input().split()))
cnt=0
ans=0
find=a
for i in range(1,N):
    if i in find:
        cnt+=1
        ans+=find.index(i)
        find=find[i+1:]
    elif i not in find:
        break
if cnt>0:
    print(ans-cnt+1)
else:
    print(-1)

N=int(input())
A=list(map(int,input().split()))
x=1
for a in A:
    if a==x:
        x+=1
    else:
        pass
if x==1:
    print(-1)
else:
    print(N-x+1)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

if A.count(1)==0:
  print('-1')
  exit()
  
if A==sorted(A):
  print('0')
  exit()

ans=0
j=1

for i in range(N):
  if A[i]==j:
    ans+=1
    j+=1
    print('OK')
  else:
    print('a')
  
print(N-ans)

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

if A.count(1)==0:
  print('-1')
  exit()
  
ans=0
j=1

for i in range(N):
  if A[i]==j:
    ans+=1
    j+=1
  
print(N-ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
A = map(int, input().split())
n,m = 1,0
if 1 not in A: print(-1)
else:
  for i in range(N):
    if A[i] == n: n += 1
    else: m += 1
  print(m)

N = int(input())
A = list(map(int, input().split()))
n,m = 1,0
if 1 not in A: print(-1)
else:
  for i in range(N):
    if A[i] == n: n += 1
    else: m += 1
  print(m)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

c = 0
e = len(A)
for i in range(e - ):
  d = 1
  if A[i] == d:
    d = d + 1
  else:
    c = c + 1

if c == e:
    print(-1)
else:
    print(c)

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

c = 0
e = len(A)
d = 1
for i in range(e):
  if A[i] == d:
    d = d + 1
  else:
    c = c + 1

if c == e:
    print(-1)
else:
    print(c)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
List_Bricks = [int(i) for i in input().split()]
#print(List_Bricks)
Search = 1
Kudaku = 0
i = 0
Boole = False
Count = 0
L = len(List_Bricks)-1
while len(List_Bricks) != 1:
    try:
        del List_Bricks[0:List_Bricks.index(Search)]
    except ValueError:
        pass
    Kudaku += List_Bricks.index(Search)
    Search += 1

N = int(input())
k = 0
for x in map(int,input().split()):
    if x == k + 1:
        k += 1
print(N-k if k else -1)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
cnt=1
for i in a:
  if i==cnt:
    cnt+=1
if cnt==1:print(-1)
else:
  print(cnt-1)

n=int(input())
a=list(map(int,input().split()))
cnt=1
for i in a:
  if i==cnt:
    cnt+=1
if cnt==1:print(-1)
else:
  print(n-(cnt-1))


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
if 1 not in a:
  print(-1)
  exit()
num_break = 0
pos = 1

for i in a:
  if i == pos:
    pos += 1
  else:
    num_break += 1

n = int(input())
a = list(map(int,input().split()))
if 1 not in a:
  print(-1)
  exit()
num_break = 0
pos = 1

for i in a:
  if i == pos:
    pos += 1
  else:
    num_break += 1
print(num_break)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
import math
A, B = map(int, input().split())
print(int(A * B / math.gcd(A, B)))


N = int(input())
A = list(map(int, input().split()))
count = 0
now = 1

for i in range(len(A)):
    if A[i] == now:
        now += 1
    else:
        count += 1

print(count if now != 1 else -1)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
R = list(map(int, input().split()))
c, i = 0, 1
for r in R:
  if r==i: i+=1
  else: c+=1
print(c if c<N else '-1')

n = int(input())
R = list(map(int, input().split()))
c, i = 0, 1
for r in R:
  if r==i: i+=1
  else: c+=1
print(c if c<n else '-1')


Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
if(1 in a):
  ans = 0
  jud = 0
  f = 1
  for i in range(n):
    if(a[0]!=f):
      del a[0]
      ans += 1
    else:
      f += 1
  print(ans)
else:
  print(-1)


n = int(input())
a = list(map(int,input().split()))
if(1 in a):
  ans = 0
  jud = 0
  f = 1
  for i in range(n):
    if(p[0]!=f):
      del p[0]
      ans += 1
    else:
      f += 1
  print(ans)
else:
  print(-1)


n = int(input())
a = list(map(int,input().split()))
if(1 in a):
  ans = 0
  jud = 0
  f = 1
  for i in range(n):
    if(a[i]!=f):
      ans += 1
    else:
      f += 1
  print(ans)
else:
  print(-1)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):

n = int(input())
lis = list(map(int,input().split()))
ans = 0
cnt = 1
for num in lis:
    if num == cnt:
        ans += 1
        cnt += 1
if ans == 0:
    print(-1)
else:
    print(ans)

n = int(input())
lis = list(map(int,input().split()))
ans = 0
cnt = 1
for num in lis:
    if num == cnt:
        ans += 1
        cnt += 1
if ans == 0:
    print(-1)
else:
    print(n-ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
lst = list(map(int, intput().split()))
x = 0
for i in lst:
  if i == x + 1:
    	x = x + 1

print(n-x)


n = int(input())
lst = list(map(int, input().split()))
x = 0
for i in lst:
  if i == x + 1:
    	x = x + 1
if x == 0:
  print(-1)
else:
  print(n-x)


Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while k<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t =+ 1
if count == N:
    print(-1)
else:
    print(count)


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
t=0

while t<len(A):
    if A[t] == k+1:
            k += 1
            t += 1
    else:
            count += 1
            t += 1
if count == N:
    print(-1)
else:
    print(count)


Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())
aN=list(input().split())
arr=[]
for a in aN:
    arr.append(int(a))

SatisfactoryOrder=False
targetNumber=1
hummer=0
if arr.count(1)<1:
    print(-1)
    exit()


# D - Brick Break

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

targetnum=1
breaknum=0

for i in range(N):
    if a[i]==targetnum:
        targetnum+=1
    else:breaknum+=1
if breaknum==N:
    print(-1)
else:
    print(breaknum)


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

if not 1 in (a):
  print(-1)
else:
  ans = 1
  for i in range(1, n+1):
    print(a)
  
    idx = np.where(a==i)[0][-1]
    ans += len(a[:idx]) - 1
    a = a[idx:]
  
    if not i+1 in a:
      print(ans + len(a) - 1)
      break

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

ans = n
check = 1
for i in range(n):
  if a[i] == check:
    ans -= 1
    check += 1
if ans == n:
  ans = -1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
nums = [int(s) for s in input().split()]

min_breaks = -1

count_num = 1
for i in range(N):
  check_num = count - nums[i]
  if nums[i] == count_num:
      if min_breaks == -1:
          min_breaks = 0
      min_break += i - count_num
      
if min_break < N:    
    print(min_break)
else:
    print(-1)

N = int(input())
nums = [int(s) for s in input().split()]
 
min_breaks = -1
 
count_num = 1

for i in range(N):
  if nums[i] == count_num:
      if min_breaks == -1:
          min_breaks = 0
      min_breaks += ((i+1) - count_num)
      count_num+=1
  
print(min_breaks)

N = int(input())
nums = [int(s) for s in input().split()]
 
min_breaks = -1
 
count_num = 1
break_index = 1

for i in range(N):
  if nums[i] == count_num:
      if min_breaks == -1:
          min_breaks = 0
      if count_num == 1:
      	 min_breaks += ((i+1) - break_index)
      else:
         min_breaks += ((i+1) - break_index - 1)
      
      break_index = (i+1)
      count_num+=1

if break_index < N and min_breaks != -1:
  min_breaks += ((i+1) - break_index)
  
print(min_breaks)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

cur=1
cnt=0
for x in xs:
    if x == cur:
        cnt += 1
        cur += 1

if cnt == 0:
    print(-1)
else:

N=int(input())
xs=map(int,input().split())

cur=1
cnt=0
for x in xs:
    if x == cur:
        cnt += 1
        cur += 1

if cnt == 0:
    print(-1)
else:
    print(N-cnt)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

ans = 0

if (1 not in a):
    print(-1)
else:
    for i in range(1,n+1):
        if (i not in a):
            ans+= len(a[i:])
            break
        else:
            ain = a.index(i)
            ans += ain-i
            del a[i:ain]
    print(ans)

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

c = 1
ans = 0

for i in a:
    if (i == c):
        c += 1
    else:
        ans += 1
if (c == 1):
    print(-1)
else:
    print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

c = [0] * n
count = 0
j = 0
if 1 not in s:
    print(-1)
elif len(s) == 1:
    print(0)
else:
    for i in range(1,n+1):
        if i in s:
            c[i] = s.index(i)
            del s[j:c[i]]
            #print(s)
            count += c[i]
            j += 1
        elif i not in s:
            break

    print(count-j)

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

c = []
j = 0
if 1 not in s:
    print(-1)
elif len(s) == 1:
    print(0)
else:
    for i in s:
        if i - j == 1:
            j = i
            c.append(i)
    print(n - len(c))

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

if (list(range(1, N + 1)) == A):
    print(0)
else:
    N = N + 1
    A.append(-1)
    for i in range(1, N + 1):
        try:
            ind = A.index(i)
            A = A[ind + 1:]
        except:
            break

    if (i == 1):
        print(-1)
    else:
        print(N - ind - 2)

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

if(list(range(1,N+1))==A):
  	print(0)
else:
    for i in range(1, N+1):
        try:
            ind = A.index(i)
            A = A[ind:]
        except:
            break
    if(i==1):
        print(-1)
    else:
        print(N-ind)

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

j = 1
for i in range(N):
    if A[i] == j:
        j = j + 1
if j == 1:
    print(-1)
else:
    print(N - j + 1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = input()
nums = list(map(int,input().split()))
print(nums)
index , pre= 0,0
max_num = 1
ans = 0
if not max_num in nums:
  print(-1)
  exit()
while 1:
  for i,n in enumerate(nums):
    if i < index:
      continue
    if n == max_num:
      index=i
      max_num+=1
      ans+=1
  if index == pre:
    if ans == 0:
      print(ans)
    else:
      print(len(nums)-ans)
    break
  pre=index

N = input()
nums = list(map(int,input().split()))
index , pre= 0,0
max_num = 1
ans = 0
if not max_num in nums:
  print(-1)
  exit()
while 1:
  for i,n in enumerate(nums):
    if i < index:
      continue
    if n == max_num:
      index=i
      max_num+=1
      ans+=1
  if index == pre:
    if ans == 0:
      print(ans)
    else:
      print(len(nums)-ans)
    break
  pre=index

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
import fractions
a,b = map(int,input().split())

def lcm(x,y):
    return (x*y) // fractions.gcd(x,y)

print(lcm(a,b))


#11037751
N = int(input())
a = list(map(int,input().split()))
now = 1
cnt = 0
for i in range(N):
    if a[i]==now:
        now += 1
print(N-now+1 if now != 1 else -1)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
l = list(map(int, input().split()))
if not 1 in l:
  print(-1)
  exit()
cnt = 1
ans = 0
for item in l:
  if item = cnt:
    ans += 1
    cnt += 1
print(n - ans)

n = int(input())
l = list(map(int, input().split()))
if not 1 in l:
  print(-1)
  exit()
cnt = 1
ans = 0
for item in l:
  if item == cnt:
    ans += 1
    cnt += 1
print(n - ans)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
An = list(map(int, input().split()))
done = 0
for i in An:
    if done+1 == i:
        done = i
    print(done,An,i)

if done == 0:
    print(-1)
else:
    print(N-done)


N = int(input())
An = list(map(int, input().split()))
done = 0
for i in An:
    if done+1 == i:
        done = i
if done == 0:
    print(-1)
else:
    print(N-done)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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


if a == [i for i in range(1, n+1)]:
    print(0)
    
else:
    b = 0
    number = 1
    for i in range(n):
        if a[i] == number:
            number += 1
        else:
            b += 1
    if b == (number - 1):
        print(b)
    else:
        print(-1)    

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


if a == [i for i in range(1, n+1)]:
    print(0)
    
else:
    b = 0
    number = 1
    for i in range(n):
        if a[i] == number:
            number += 1
        else:
            b += 1
    if number == 1:
        print(-1)
    elif b == (n - number + 1):
        print(b)
    else:
        print(-1)    

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):

def main():
    ind = int(input())
    t = list(map(int, input().split()))
    ans = []
    for i in range(ind):
        if len(ans) + 1 == t[i]:
            ans.append(t[i])
    count = -1 if len(ans) == 0 else ind - len(ans)
    print(ans)
    print(count)



if __name__ == '__main__':
    main()


def main():
    ind = int(input())
    t = list(map(int, input().split()))
    ans = []
    for i in range(ind):
        if len(ans) + 1 == t[i]:
            ans.append(t[i])
    count = -1 if len(ans) == 0 else ind - len(ans)
    print(count)



if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N = int(input())
alist = list(map(int, input().split()))
left = 0
for i in range(1, N + 1):
    try:
        old_left = left
        left = alist[left:].index(i)
        p = left + old_left
    except ValueError:
        print(i, p)
        if i == 1:
            print(-1)
        else:
            print(N - i + (N - p))
        break
else:
    print(0)


N = int(input())
alist = list(map(int, input().split()))
now = 1
for a in alist:
    if a == now:
        now += 1
if now == 1:
    print(-1)
else:
    print(N - now + 1)


Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
quantity = int(input())
block = list(map(int,input().rstrip().split(" ")))

print(block)

num = 1
for i in block:
    if i == num:
        num += 1

if num == 1:
    print(0)
else:
    print(quantity - num + 1)

uantity = int(input())
block = list(map(int,input().rstrip().split(" ")))

print(block)

num = 1
for i in block:
    if i == num:
        num += 1

if num == 1:
    print(0)
else:
    print(quantity - num + 1)
    

quantity = int(input())
block = list(map(int,input().rstrip().split(" ")))

num = 1
for i in block:
    if i == num:
        num += 1

if num == 1:
    print(-1)
else:
    print(quantity - num + 1)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

now = 1
for ai in a:
    if ai == now:
        now += 1

if now == 1:
    print(-1)
else:
    print(N - now + 2)


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

now = 1
for ai in a:
    if ai == now:
        now += 1

if now == 1:
    print(-1)
else:
    print(N - now + 1)


Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

if n%2 or n < 10:
    print(0)
    exit()

ans = 0
cnt = 1
while 2*(5**cnt) <= n:
    ans += n//(2*(5**cnt))
    cnt+=1
print(ans)

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

cnt = 0
cur = 1

for i in nums:
    if i == cur:
        cur+=1
    else:
        cnt+=1
if cur == 1:
    print(-1)
else:
    print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
hoge=list(map(int,input().split()))
flag=1
punch=0
for i in range(n):
  if(hoge[i]==flag):
    flag+=1
  else:
    punch+=1
    
if(punch==n):
  print(-1)
else:
  print(n-punch)

n=int(input())
hoge=list(map(int,input().split()))
flag=1
punch=0
for i in range(n):
  if(hoge[i]==flag):
    flag+=1
  else:
    punch+=1
    
if(punch==n):
  print(-1)
else:
  print(punch)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
import sys
readline = sys.stdin.buffer.readline
 
n = int(readline())
num = 1
res = 0
for i in readline().split():
  if num != int(i):
    res += 1
  else:
    i += 1

if res == n:
  print(-1)
else:
  print(res)

import sys
readline = sys.stdin.buffer.readline
 
n = int(readline())
num = 1
res = 0
for i in readline().split():
  if num != int(i):
    res += 1
  else:
    num += 1
if res == n:
  print(-1)
else:
  print(res)

Verdicts: Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())
b=list(map(int,input().split()))
var=1
_break=0
for i in range(N):
  if b[i] != var:
    _break+=1
    
  var+=1
  
if _break==N:
  print(-1)
else:
  print(_break)

N=int(input())
b=list(map(int,input().split()))
var=1
_break=0
for i in range(N):
  if b[i] != var:
    _break+=1
    
  else:
    var+=1
  
if _break==N:
  print(-1)
else:
  print(_break)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
N=int(input())
number=input().split(' ')
number_list=[]
index=1
flag=0
for i in number_list:
    if(i==1):
        flag=1
    elif i==index:
        index+=1

if(flag==0):
    print(-1)
else:
    print(index)

a,b=(int(x) for x in input().split())
gcc=1
i=2
while True:
    if(a<i or b<i):
        break
    elif (a%i==0 and b%i==0):
        gcc*=i
        a/=i
        b/=i
        i=2
    else:
        i+=1

print(int(a*b*gcc))


N=int(input())
number=input().split(' ')
number_list=[]
for i in number:
    number_list.append(int(i))
index=1
flag=0
count=0
for i in number_list:
    if(i==1 and flag==0):
        flag=1
        index+=1
    elif (i==index):
        index+=1
    else:
        count+=1

if(flag==0):
    print(-1)
else:
    print(count)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

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

i = 1
ind = 0
if 1 in a:
    while i in a[ind:]:
    	ind = a.index(i)
    	i += 1
    	print(n-i+1)
else:
    print(-1)


n = int(input())
a = list(map(int,input().split()))
k = 1

for i in a:
    if k == i:
        k += 1

if k == 1:
    print(-1)
else:
    print(k-1)

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

i = 1
if 1 in a:
    while i in a:
        del a[:a.index(i)]
        i += 1
        print(n-i+1)
else:
    print(-1)

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

i = 1
ind = 0
if 1 in a:
    while i in a[ind:]:
    ind = a.index(i)
    i += 1
    print(n-i+1)
else:
    print(-1)


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

i = 1
if 1 in a:
    while i in a:
    del a[:a.index(i)]
    i += 1
    print(n-i+1)
else:
    print(-1)

n = int(input())
a = list(map(int,input().split()))
k = 1

for i in a:
    if k == i:
        k += 1

if k == 1:
    print(-1)
else:
    print(n-k+1)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
# abc148_d.py
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
print(a)
cnt = 0
idx = 1
flg = 1
for i in a:
	if i == idx:
		idx = idx + 1
		flg = 0
	else:
		cnt = cnt + 1
		if idx != 1:
			flg = 1

if flg == 1:
	print(-1)
else:
	print(cnt)



# abc148_d.py
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
#print(a)
cnt = 0
idx = 1
#flg = 1
for i in a:
	if i == idx:
		idx = idx + 1
		#flg = 0
	else:
		cnt = cnt + 1
		#if idx != 1:
			#flg = 1

if cnt == N:
	print(-1)
else:
	print(cnt)



Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

want=1
ans=0
for i in range(N):
    if A[i]==want:
        want+=1
    else:
        ans+=1

if A[i]!=1:
    print(-1)
else:
    print(ans)

# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

want=1
ans=0
log=-1
for i in range(N):
    if A[i]==want:
        if want==1:
            log=i
        want+=1
    else:
        ans+=1

if log==-1:
    print(-1)
else:
    print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
cnt = 1
for i in a:
  if i == cnt:
    cnt += 1
print(n - cnt)


n = int(input())
a = list(map(int,input().split()))
cnt = 1
for i in a:
  if i == cnt:
    cnt += 1
print(n + 1 - cnt if cnt > 1 else -1)

Verdicts: Wrong Answer

Accepted
Problem: We have N bricks arranged in a row from left to right.  The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.  Among them, you can break at most N-1 bricks of your choice.  Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.  Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
if not 1 in a:
    print(-1)
else:
    for i in range(1,n):
        if i in a:
            index=a.index(i)
            a=a[index:]
        else:
            break
    print(n-i+1)

n=int(input())
a=list(map(int,input().split()))
now=1
rtn=0
for i in range(n):
    if a[i]==now:
        rtn+=1
        now+=1
if rtn:
    print(n-rtn)
else:
    print(-1)

Verdicts: Runtime Error

Accepted