結果

問題 No.1374 Absolute Game
ユーザー HIcoderHIcoder
提出日時 2023-07-19 23:46:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 114,208 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 02:00:39
合計ジャッジ時間 3,059 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 16 ms
4,348 KB
testcase_09 AC 40 ms
4,348 KB
testcase_10 AC 45 ms
4,348 KB
testcase_11 AC 28 ms
4,348 KB
testcase_12 AC 18 ms
4,348 KB
testcase_13 AC 35 ms
4,348 KB
testcase_14 AC 51 ms
4,348 KB
testcase_15 AC 51 ms
4,348 KB
testcase_16 AC 52 ms
4,348 KB
testcase_17 AC 51 ms
4,348 KB
testcase_18 AC 51 ms
4,348 KB
testcase_19 AC 51 ms
4,348 KB
testcase_20 AC 20 ms
4,348 KB
testcase_21 AC 27 ms
4,348 KB
testcase_22 AC 50 ms
4,348 KB
testcase_23 AC 7 ms
4,348 KB
testcase_24 AC 9 ms
4,348 KB
testcase_25 AC 10 ms
4,348 KB
testcase_26 AC 17 ms
4,348 KB
testcase_27 AC 24 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set> 
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
#include<cassert>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;


int main(){

    int N;
    cin>>N;
    vector<ll> c(N);
    for(int i=0;i<N;i++){
        cin>>c[i];
    }

    ll ans=-INF;

    sort(c.begin(),c.end());
    for(int t=0;t<2;t++){
        
        vector<ll> sum(2,0);
        for(int i=0;i<N;i++){
            sum[i%2]+=c[i];
        }

        //ll d=sum[0] - sum[1];//abs(sum[0]) - abs(sum[1]);

        ll d=abs(sum[0]) - abs(sum[1]);
        ans=max(ans,d);

        reverse(c.begin(),c.end());
    }

    cout<<ans<<endl;




}
0