class Solution {
public:
    
    void swap(int *p, int *q){
        int temp = *p;
        *p = *q;
        *q = temp;
    }
    
    int adjustBigHeap(vector<int> &arr){
        int size = arr.size();
        int big1 = -999;
        //if(size%2!=0) arr.push_back(-999);
        for(int i = size/2-1 ; i>=0; i--){
            if(arr[i]>arr[2*i]) swap(&arr[i],&arr[2*i]);
            if(2*i+1<=size&&arr[i]>arr[2*i+1]) swap(&arr[i],&arr[2*i+1]);
        }
        big1 = arr[0];
        swap(&arr[0], &arr[size-1]);
        arr.pop_back();
        return big1;
    }
    
    vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
        vector<int> ans;
        for(int i=0; i<k; i++){
            int temp = adjustBigHeap(input);
            ans.insert(ans.begin()+i, temp);
        }
        return ans;
    }
};