解法: We will solve the problem with the help of dynamic programming.
dp[i][j] is the minimum amount of energy that should be spent to make first i strings sorted in lexicographical order and i-th of them will be reversed if j = 1 and not reversed if j = 0.
dp[i][j] is updated by dp[i - 1][0] and dp[i - 1][1].
It remains to verify that the i-th string is lexicographically greater than (i - 1)-th (if j = 1 then we should check reversed i-th string, similar to (i - 1)-th).