time limit exceed

there is a question on codechef that has time limit 1.5 sec. on that question it give time limit exceed error on submiting but on other side codechef compiler execute the same code in 0 sec. then why it show such a error. .

The amount of time taken usually depends on the test data.

Generally speaking, some of the test cases used on submission will be designed to take a long time unless good algorithms are used. Check the limits on the variables given in the problem and you can bet that one of the test cases will have values all near (/up to) the maximum limits (assuming that gives the worst-case running time).

//