Totally misinterpreted the problem inputs. The number of groups is given and group length was to be calculated. I did the opposite :-(
Fixed that and Got AC :-)