1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; typedef long long ll; ll sz[100001]; ll a[100001]; inline void _read(ll &x) { x = 0; char t = getchar(); while (!isdigit(t)) t = getchar(); while (isdigit(t)) { x = x * 10 + t - '0'; t = getchar(); } } inline void _read(int &x) { x = 0; char t = getchar(); while (!isdigit(t)) t = getchar(); while (isdigit(t)) { x = x * 10 + t - '0'; t = getchar(); } } int n; int () { _read(n); register ll ans = 0; for (register int i = 1;i <= n;i ++) _read(a[i]); for (register int i = 1;i <= n;i ++) { register ll qwe = min (a[i], a[i + 1]); if ((a[i] - qwe) & 1 && qwe) qwe--; ans += qwe; a[i] -= qwe; a[i + 1] -= qwe; ans += a[i] / 2; } printf("%lld", ans); return 0; }
|
近期评论