贪心处理,每一个数优先和自己相等的数匹配,其次和比自己大一位的匹配即可。
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
const int maxn = 1e5 + 10;
#define ll long long
int n;
int a[maxn];
ll ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (int i = 1; i <= n; i++) {
ans += a[i] / 2;
a[i] %= 2;
if (a[i] && i < n && a[i+1] ) {
a[i] = 0;
a[i + 1] -= 1;
ans++;
}
}
cout << ans << endl;
return 0;
return 0;
}