結果
問題 | No.2856 Junk Market Game |
ユーザー | umezo |
提出日時 | 2024-08-25 14:58:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 3,172 ms |
コンパイル使用メモリ | 254,188 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-25 14:58:49 |
合計ジャッジ時間 | 4,526 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; template <class T> using V=vector<T>; template <class T> using VV=V<V<T>>; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; n*=2; V<ll> A(n),B(n); rep(i,n) cin>>A[i]; rep(i,n) cin>>B[i]; V<array<ll,3>> C(n); rep(i,n) C[i]={A[i]+B[i],A[i],B[i]}; sort(ALL(C)); ll a=0,b=0; rep(i,n){ if(i%2==0) a+=C[i][1]; else b+=C[i][2]; } cout<<a-b<<endl; return 0; }