i am new to codechef .i want to improve my skills.but i tried many problems to solve.but during compilation it runs successfully in my computer but while i submit there occurs an error:time out of bound.i already posted a question about this 8 hours ago.but nobody replied.anyone could help me please?and i want some words about how to shine in coding.i know c and python.but i use python.am i going in an right path.
Mostly, if you are getting a TLE on a supposedly correct solution, it’s because your code complexity is not the best possible for the problem. For example, if you are given a very large sorted array and you linearly search for an element, you will get a TLE(you must do a binary search). If you are having trouble solving an “Easy” problem, try solving a few “Beginner” first. I can see that you have made only four attempts till now, well that’s nothing! Be prepared for even harsher rejection here.
Finally, I’ll leave this thread here just in case but I don’t think you need to go through this.
I am also copy pasting psaini’s comments on your previous post in case you didn’t read it. Please make sure that you understand the calculations made here so that you yourself can predict in future if your code is going to get TLE:
Your code loops from 3 to n ( while(i!=n): i=i+1 ). n can be as large as 10^{12}. The time limit for the question is 2 seconds and in 1 second, codechef servers can do around 10^8 operations. Your code will take about 1000 seconds per test case. Obviously you’ll exceed the time limit.
Also you can just post a link to your submission instead of just writing you code here. You can find your submissions by clicking on “My submisions” on the problem page.
Try to find an algorithm which takes less time. If you can’t then comment here and I’ll post a thread discussing the solution.
Please at least try to use symbols to convey your intention. Theres a huge difference in saying “codechef servers can do around 108 operations.” and “codechef servers can do around 10^8 (or 10^8) operations.”