completed naive algo for energy question, tested with sample input
naive algo correctness varified