• + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    #

    Complete the 'cookies' function below.

    #

    The function is expected to return an INTEGER.

    The function accepts following parameters:

    1. INTEGER k

    2. INTEGER_ARRAY A

    #

    def insert(A,k): A.append(k) i=len(A)-1 while i>0: if A[i]

    def heapify(A,n,i): left=2*i+1 right=2*i+2 smallest=i if (leftA[left]): smallest=left if(rightA[right]): smallest =right if smallest!=i: A[i],A[smallest]=A[smallest],A[i] heapify(A,n,smallest)

    def heapi(A): i=(len(A)+1)//2 while(i>=0): heapify(A,len(A),i) i-=1 return A

    def cookies(k, A): # Write your code here heapi(A) count=0 j=0 m=len(A) while(len(A)!=1 and j j+=1

    if A[0]<k:
        return -1
    return count
    

    if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')

    first_multiple_input = input().rstrip().split()
    
    n = int(first_multiple_input[0])
    
    k = int(first_multiple_input[1])
    
    A = list(map(int, input().rstrip().split()))
    
    result = cookies(k, A)
    
    fptr.write(str(result) + '\n')
    
    fptr.close()