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

Ended

Participants:163

Verdict:Accepted
Score:100 / 100
Submitted:2017-12-10 12:07:18

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
#include<algorithm>
using namespace std;
const int N =1e5+5;
int a[2*N]; 
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<2*n;i++){
            scanf("%d",&a[i]);
        }
        sort(a,a+2*n);
        long long ans = 0;
        for(int i=1;i<n;i++){
            ans += (long long)a[i];
        }
        ans+=(long long)a[2*n-1];
        printf("%lld\n",ans);
    }
} 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX