DMOPC '14 Contest 1 P1 - Median Mark
Source Code
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
int arr[n];
for(int i = 0; i < n; i++){
cin >> arr[i];
}
sort(arr, arr + n);
if(n % 2 == 0){
cout << (int)round(1.0 * (arr[n / 2] + arr[n / 2 - 1]) / 2);
}else{
cout << arr[n / 2];
}
return 0;
}