はまやんはまやんはまやん

hamayanhamayan's blog

Domino for Young [Codeforces Round #609 (Div. 1) B]

https://codeforces.com/contest/1268/problem/B

解説

https://codeforces.com/contest/1268/submission/67379641

天才力が試されている。
黒と白の市松模様でマスを塗ると、min(黒の個数, 白の個数)が答え。

int N, A[301010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    ll black = 0, white = 0;
    rep(i, 0, N) {
        int v[2] = { A[i] / 2, A[i] - A[i] / 2 };
        black += v[i % 2];
        white += v[1 - (i % 2)];
    }

    ll ans = min(black, white);
    cout << ans << endl;
}