Lack of fitness - 3 times a week was not enough. You are not used to the hills and probably pushed too hard. This is a tough sport and I seem to recall that ride is tough. It does not take much to use up your stores of muscle glycogen. The theory that eating as your ride is a good one IF you have the fitness to digest and use the food you are consuming as you ride. One of the things that training over years thousands of miles per year provides is the body's ability to channel resources (digestion, blood flow, lactate burned as fuel and etc.) as your body needs it to support powering a bicycle. This adaptation takes a long time and we are all individuals. Rome was not built in a day.