よじろめ覚書

私の理解度重視のソースコードです。

ABC088B - Card Game for Two

問題:B - Card Game for Two

#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define PB push_back

int main(void) {
    int n, a, ans = 0;
    vector<int>vec;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) {
        cin >> a;
        vec.PB(a);
    }
    
    sort(vec.begin(), vec.end(), greater<int>());
    REP(i, n) {
        ans += (i % 2)? vec[i] * (-1) : vec[i];
    }
    cout << ans << "\n";
    return 0;
}