結果

問題 No.1374 Absolute Game
ユーザー tempura_pp
提出日時 2019-03-24 02:07:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 1,775 ms
コンパイル使用メモリ 168,904 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-02 10:09:18
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 5 WA * 21
権限があれば一括ダウンロードができます

ソースコード

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];
    sort(a,a+n);
    ll ans=0;
    rep(i,n){
        if(ans%2)ans-=a[i];
        else ans+=a[i];
    }
    cout<<abs(ans)<<endl;
    return 0;
}
0