题解 | #Median#
Median
https://www.nowcoder.com/practice/b5da3f56557f42978ca87afedbd85fbe
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> v; int n, x; while (cin >> n) { // 注意 while 处理多个 case while(n -- && cin >> x) v.push_back(x); } sort(v.begin(), v.end()); int len = v.size(); if(len & 1) cout << v[len >> 1]; else cout <<v[len - 1 >> 1]; } // 64 位输出请用 printf("%lld")