黑白染色簡化思惟

黑白染色簡化思惟


【問題背景1】: Codeforces 1269D. Domino for Young
在這裏插入圖片描述
在這裏插入圖片描述c++

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int N = 3e5 + 10; 
bool f;
ll n, x;
ll num[2];
int main() 
{
	scanf("%lld", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lld", &x);
		f = !f;
		ll div2 = x / 2;
		num[!f] += div2;
		num[f] += x - div2;
	}
	printf("%lld", min(num[0], num[1]));
	return 0;
}