I have tried the same approach to solve @CHEFSTEP which almost everyone had given in the contest but my c++ solution is giving TLE, I don’t know why?
And today when I did it with python the solution got accepted…
I wanted to know my mistake so that I may not repeat it…Please help.
My C++ code:-
[CodeChef: Practical coding for everyone]
Yes. But don’t use it for interactive problems. And if you’re using this, do not use C style printing functions like puts() or printf(). This will mess up the order in which things are printed.
Don’t use this for interactive problems, because you’ll have to flush the output at each and every step, which the judge reads and gives corresponding information.
It doesn’t matter in C++ if there is every input in one line seperated by a space or given in a new line . Can’t say about this format in other languages
e.g. 1 5 3 12 13 18 20 27216 this will also give the same output in CHEFSTEP problem
I guess that it is true for any language. The only problem is when you use int a[] = sc.readArray() in JAVA, (assuming you have a readArray() function in your reader class) or a = list(map(int, input().split())) in Python.
There shouldn’t be a problem even in JAVA and Python if we use a loop to read the next integer.
The input for this question is quite large, and traditional input methods take time reading it. If the time limit was 2 seconds, I guess fast input won’t be required.
Sir,could you please tell me How to improve my ratings?? As I am trying my best to do so,but if you check my profile once my ratings is going worse day by day…
We cant really say what happens while running. Probably yours took 0.9 seconds and just passed the limit, while his would’ve finished at 1.1 sec, but it was stopped right after 1.0 sec and given a TLE verdict.
@dashing123 I would say, don’t worry about your rating right now. Just keep solving contests and problems and keep learning. Your rating will automatically improve in the future.