Codeforces Educational Round 16 B.Optimal Point on a Line
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define high 300010
typedef long long LL;
LL ar[high];
int main()
{
fast;
LL n;
while(cin >> n)
{
LL i;
for(i=0; i<n; i++)
{
cin >> ar[i];
}
sort(ar, ar+n);
LL ans = (n&1) ? ar[n/2] : ar[n/2 - 1];
cout << ans << "\n";
}
return 0;
}
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define high 300010
typedef long long LL;
LL ar[high];
int main()
{
fast;
LL n;
while(cin >> n)
{
LL i;
for(i=0; i<n; i++)
{
cin >> ar[i];
}
sort(ar, ar+n);
LL ans = (n&1) ? ar[n/2] : ar[n/2 - 1];
cout << ans << "\n";
}
return 0;
}
Comments
Post a Comment