#K58092. Maximum Room Occupancy
Maximum Room Occupancy
Maximum Room Occupancy
Given an integer \(N\) representing the number of hours, and a list of \(N\) integers where each integer represents the net change (number of people entering or leaving) in the room for that hour, determine the maximum number of people present in the room at any time. Assume that the room starts with zero people. The occupancy at the \(i^{th}\) hour can be computed as:
\[ C_i = \sum_{j=1}^{i} a_j \]
Your task is to find \(\max_{1 \le i \le N} \{C_i\}\). If the occupancy becomes negative, consider it as is; however, since we start at 0 and track the maximum, the answer will never be less than 0.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(N\) (\(1 \le N \le 10^5\)), representing the number of hours.
- The second line contains \(N\) space-separated integers, where each integer \(a_i\) (\(|a_i| \le 10^4\)) represents the net change of people in the room during the \(i^{th}\) hour.
outputFormat
Output a single integer to standard output (stdout) – the maximum occupancy of the room at any given time.
## sampleEOF
5
10 -3 5 -2 8
EOF
18