POJ_2388 Who's in the Middle
問題
英語でなんかいろいろ書かれているが、ようは中央値をもとめよということ
解法
ソートして真ん中の値を取り出すだけ。
#include <cstdio> #include <algorithm> using namespace std; const int MAX = 10001; int d[MAX]; int N; int main(){ scanf("%d", &N); for(int i = 0; i < N; i++){ scanf("%d", &d[i]); } sort(d, d + N); printf("%d\n", d[N/2]); return 0; }