結果

問題 No.1374 Absolute Game
ユーザー tempura_pptempura_pp
提出日時 2019-03-24 02:15:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 166,576 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 08:26:18
合計ジャッジ時間 3,135 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 15 ms
6,940 KB
testcase_09 AC 37 ms
6,940 KB
testcase_10 AC 41 ms
6,940 KB
testcase_11 AC 27 ms
6,940 KB
testcase_12 AC 18 ms
6,944 KB
testcase_13 AC 32 ms
6,940 KB
testcase_14 AC 49 ms
6,940 KB
testcase_15 AC 48 ms
6,940 KB
testcase_16 AC 52 ms
6,940 KB
testcase_17 AC 50 ms
6,944 KB
testcase_18 AC 49 ms
6,940 KB
testcase_19 AC 47 ms
6,944 KB
testcase_20 AC 17 ms
6,944 KB
testcase_21 AC 25 ms
6,944 KB
testcase_22 AC 49 ms
6,944 KB
testcase_23 AC 7 ms
6,940 KB
testcase_24 AC 8 ms
6,940 KB
testcase_25 AC 10 ms
6,940 KB
testcase_26 AC 17 ms
6,944 KB
testcase_27 AC 22 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int main(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll sum[2][4];
    rep(i,2)rep(j,4)sum[i][j]=0;
    sort(a,a+n);
    rep(i,n){
        sum[i%2][0]+=a[i];
    }
    rep(i,n){
        sum[i%2][1]+=a[n-i-1];
    }
    rep(i,n){
        if(2*i<=n)sum[0][2]+=a[i];
        else sum[1][2]+=a[i];
    }
    rep(i,n){
        if(2*i<n)sum[1][3]+=a[i];
        else sum[0][3]+=a[i];
    }
    ll ret[4];
    rep(i,4)ret[i]=abs(sum[0][i])-abs(sum[1][i]);
    cout<<max(min(ret[0],ret[2]),min(ret[1],ret[3]));

    return 0;
}
0