and judge submitted this source as "time limit exceed"
what i want to know is which strategy i should use. and the mistake that i missed. please give me some help.
p.s, please use simple english. because i'm from a country where english is not mothertongue..
but,, i cannot remind any algorithm however hard i tried... please give me some idea..
(that's why i choosed back tracking for last solution(which is time-consuming))
That is part of being a programmer. You have to learn to make your own algorithms for problems. You don't necessarily have to use existing ones. Hobbyist or professional, you have to learn to do it yourself or you will keep doing this with every project you do.