#include <vector>
class Solution {
public:
    void Insert(int num) {
        nums.push_back(num);
        size++;
	  	//插入后直接进行排序
        if(size >= 2 && nums[size-1] < nums[size-2])
        {
            int temp = nums[size-1];
            int i = size-2;
            while(i>=0 && nums[i] > temp)
            {
                nums[i+1] = nums[i];
                i--;
            }
            nums[i+1] = temp;
        }
    }

    double GetMedian() { 
        if(size % 2  == 0)
        {
            return static_cast<double>(nums[size/2-1]+nums[size/2])/2;
        }
        else {
            return nums[size/2];
        }
    
    }
private:
    vector<int> nums;
    int size = 0;
};