-
-
Save theoremoon/1063dcafee00f33bb117906387c39f94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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