Editorial for Inaho V
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
The intended solution for this problem was to use unsigned integers.
For the first subtask, it is sufficient to use a signed 64-bit integer, since the final answer will not underflow.
For the second subtask, one can treat the input as positive integers, and negate the final answer at the end while printing. For each of the nonpositive integers, one can read them in as signed 64-bit integers, negate them, and add them to the unsigned 64-bit integer. Finally, while printing the answer, one can print a -
sign in front of the answer to negate it.
It should be noted that printing -0
is invalid and will result in Wrong Answer.
Alternatively, one can implement their own big integer library, though this is overkill.
Time Complexity:
Comments