公平分队
#pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<iostream> #include<map> #include<queue> #include<stack> #include<string> #include<functional> //#include<bits/stdc++.h> using namespace std; typedef long long lint; typedef vector<int> VI; typedef pair<int, int> PII; int cmp(const void * x, const void * y) { #define datatype int datatype dx = *((datatype *)(x)), dy = *((datatype *)(y)); //x < y return dx < dy ? -1 : 1; #undef datatype } int a[200005]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif std::ios::sync_with_stdio(0), cin.tie(0); int n; cin >> n; for (int i = 0; i < 2 * n; i++) cin >> a[i]; sort(a, a + 2 * n); lint ans = 0; for (int i = 1; i < n; i++) ans += a[i]; ans += a[2 * n - 1]; cout << ans << endl; return 0; }