[Offer收割]编程练习赛39 register

Ended

Participants:163

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-10 12:09:16

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
#define FI first
#define SE second
int mod = 1000000007;
const int N = 200010;
int rec[N];
int main() 
{
    // freopen("in.txt", "r", stdin);
    int n;
    while (~scanf("%d", &n))
    {
        int m = n<<1;
        for (int i = 0; i < m; i++)
            scanf("%d", rec + i);
        sort(rec, rec + m);
        ll sum = 0;
        swap(rec[0], rec[m-1]);
        for (int i = 0; i < n; i++)
            sum += rec[i];
        printf("%lld\n", sum);
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX