結果

問題 No.1374 Absolute Game
ユーザー HIcoderHIcoder
提出日時 2023-07-19 23:46:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 114,248 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 02:00:20
合計ジャッジ時間 3,075 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 WA -
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 AC 17 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 29 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 52 ms
4,348 KB
testcase_16 WA -
testcase_17 AC 52 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 52 ms
4,348 KB
testcase_20 AC 21 ms
4,348 KB
testcase_21 AC 27 ms
4,348 KB
testcase_22 AC 52 ms
4,348 KB
testcase_23 AC 7 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 11 ms
4,348 KB
testcase_26 AC 17 ms
4,348 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

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;

    for(int t=0;t<2;t++){
        sort(c.begin(),c.end());
        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