eolymp
bolt
Try our new interface for solving problems
Problems

Median of numbers

published at 4/4/24, 7:46:42 pm

include <bits/stdc++.h>

define ll long long int

define ld long double

using namespace std; int main(){

ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
vector<ll>v;
while(cin>>n){
    v.push_back(n);
}
sort(v.begin(), v.end());
ll k = v.size()/2;
if(v.size() %2 != 0){
    cout<<v[k];
    return 0;
}
ll m = v[k] + v[k-1];
cout<<-1;

} //TECHNOBLADE NEVER DIES