【題解】Codeforces 1300B. Assigning to Classes

【題目敘述】http://codeforces.com/contest/1300/problem/B

#include <iostream>
#include <algorithm>
using namespace std;
 
int t, n, a[200005];
 
int main() {
    cin >> t;
    while (t--){
        cin >> n;
        for (int i = 0; i < n*2; i++){
            cin >> a[i];
        }
        sort(a, a+n*2);
        cout << a[n]-a[n-1] << "\n";
    }
}
分享本文 Share with friends