Doubt in SUBMEDIA question

MY Approach
First, find out the n-k minimum elements from the array and remove them then find the median of the remaining elements which would be our maximum median.

int n, k;
    cin >> n >> k;
    vector<int> org(n);
    vector<pair<int, int>> dup(n);
    // duplicate array for storing the numbers with their indexes
    for (int i = 0; i < n; i++)
        cin >> org[i];
        dup[i].first = org[i];
        dup[i].second = i;
    // sorting the duplicate array
    sort(dup.begin(), dup.end());
    // finding the first n-k elements of the duplicate array in the original array and making them as -1,as they do not contribute to our required sequence
    for (int i = 0; i < (n - k); i++)
        org[dup[i].second] = -1;
    // printing the middle element in the duplicate vector,excluding the n-k elements
    cout << dup[(n - k) + k / 2].first << endl;
    // printing the elements of the orginal array whose value is not set -1
    for (int i = 0; i < n; i++)
        if (org[i] != -1)
            cout << org[i] << " ";

this is my code ,does anyone say why does not work.