What is the problem with this code for BUY1GET1. I have uploaded two program first was working fine but exceeded the time limit. so I changed the algorithm and this is the result. I have tried several test cases, out comes correctly in my system. I also tried testing both my programs, with same inputs and they produce same results. but the judge gives “Wrong Answer” for my second program. where did I go wrong??
(code removed by @cyberax)