Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
580 B
0
Indexable
Never
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, m, a, l, h; cin >> n >> m;
    vector<int> V;
    vector<int> median;
    for (int i = 0; i < n; i++)
    {
        for (int i = 0; i < m; i++)
        {
            cin >> a;
            V.push_back(a);
        }
        sort(V.begin(), V.end());
        h = ((V.size() - 1) / 2 + 1);
        median.push_back(V[h - 1]);
        V.clear();
    }
    sort(median.begin(), median.end());
    l = (median.size() - 1) / 2 + 1;
    cout << median[l-1];
}