Maximum of absolute values#914

Maximum of absolute values (Editorial)

Written By : MathModel

We read numbers as double/floats , and we perform a_i=|a_i| or

\begin{cases} a_i \gets a_i , \text{ if } a_i \ge 0 \\ a_i \gets -a_i , \text{ if } a_i < 0 \\ \end{cases}

for all indices .

We iterate through the array and get the maximum number , and then we print with 2 decimal places.

n=int(input())
a=map(float,input().split())
a=map(abs,a)
mx=0
for i in a:
    mx=max(mx,i)
print(f"{mx:.2f}")