結果

問題 No.1374 Absolute Game
ユーザー poohbearpoohbear
提出日時 2021-02-05 21:26:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 2,110 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 203,964 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-15 07:09:52
合計ジャッジ時間 3,923 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 15 ms
4,376 KB
testcase_09 AC 36 ms
4,508 KB
testcase_10 AC 42 ms
4,376 KB
testcase_11 AC 26 ms
4,380 KB
testcase_12 AC 17 ms
4,376 KB
testcase_13 AC 32 ms
4,376 KB
testcase_14 AC 48 ms
4,380 KB
testcase_15 AC 48 ms
4,380 KB
testcase_16 AC 49 ms
4,380 KB
testcase_17 AC 47 ms
4,376 KB
testcase_18 AC 48 ms
4,376 KB
testcase_19 AC 48 ms
4,380 KB
testcase_20 AC 18 ms
4,376 KB
testcase_21 AC 26 ms
4,380 KB
testcase_22 AC 47 ms
4,376 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 9 ms
4,380 KB
testcase_26 AC 16 ms
4,376 KB
testcase_27 AC 22 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
const ll INF = 1e18+7;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template<typename T> 
inline void prt(vector<vector<T> >& vv){ for(const auto& v : vv){ prt(v); } }
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

/*
方針
sortした状態で考える

*/


int main(){
	ll n;
	cin >> n;
	vector<ll>c(n);
	rep(i,n)cin>>c[i];
	sort(c.begin(),c.end());
	ll a = 0;
	ll b = 0;
	rep(i,n){
		if(i%2==0)a+=c[i];
		else b+=c[i];
	}
	cout << abs(abs(a)-abs(b)) << endl;
	
	return 0;
}
0