Official

A - モニタリングの最高値 / Monitoring Peak Editorial by admin

swe-2-high

Explanation

We need the maximum load level over \(N\) days. Each character of \(S\) is a digit 0–9, so c - '0' converts a character into the integer load level for that day.

The program initializes best to \(0\) and scans \(S\) left to right, updating best = max(best, c - '0'). Since best always holds the largest value seen so far, after the scan it equals the overall maximum. Starting at \(0\) is safe because every level is at least \(0\).

Each character is processed once, giving \(O(N)\) time. Storing the input string takes \(O(N)\) space and only a constant number of extra variables are used, so space is \(O(N)\).