Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created April 1, 2020 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theoremoon/1063dcafee00f33bb117906387c39f94 to your computer and use it in GitHub Desktop.
Save theoremoon/1063dcafee00f33bb117906387c39f94 to your computer and use it in GitHub Desktop.
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
std.typecons, std.math, std.container, std.format, std.numeric;
void main(string[] args)
{
long n;
readf("%d\n", &n);
long ans = 0;
long before = 0;
long a;
foreach (i; 0 .. n)
{
readf("%d\n", &a);
long b = a + before;
ans += b / 2;
before = (a == 0) ? 0 : b % 2;
}
writeln(ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment