Problems > Raise Everyone Up > Editorial

Raise Everyone Up — Solution & Editorial

Back to the Problem

Only raising is allowed, so the target is the current maximum: N·max − sum.

Complexity: O(N)

Watch out: N·max needs 64 bits.