During the SRM, I coded the following approach:

If the array consists of (n - 1) ones then return n. Otherwise just sum the expected value of each of the dice and round down to the nearest integer. This cleared the examples. As I could not find any case which broke the code, I submitted it. What is wrong with the approach and what is the correct approach? I tried reading others’ code but could not understand the logic.

The problem statement: TopCoder Statistics - Problem Statement

My (wrong) solution: TopCoder | Login