题意:
解法:
贪心.
然后对于每个a[i],优先和a[i-1]匹配,然后自匹配,如果还有多出来的就留给a[i+1].
code:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxm=2e5+5;
int a[maxm];
int n;
void solve(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int ans=0;
ans+=a[1]/2;
a[1]%=2;
for(int i=2;i<=n;i++){
int t=min(a[i],a[i-1]);
ans+=t;
a[i]-=t;
ans+=a[i]/2;
a[i]%=2;
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(0);
solve();
return 0;
}