what to do to solve all the subtasks

Actually I always get this problem. I solve the question and its only partially completed…why this happen?what should i do to remove these problems and solve the problem completely

One thing every beginner do is to get straight to the question after reading it . You should give it some time to analyse its accepted complexity and try to code to match the range of test cases within the time limit . Usually brute force solution lead to partially accepted when the test cases are really large .

Thanks I will keep this in mind now…

in layman terms, you should try to think of an algorithm whose overall complexity is around 10^8 (by using the constraints given in the statement and analysing the asymptotic behaviour of your code)

Time efficiency is the main thing. Is your code efficient enough to pass for all the large test cases? Many users are able to write correct codes, but they arent efficient. Their approaches perform a lot of waste/redundant/useless operations and consume unnecessary time.

The same sorting algorithm which takes 0.1 second for large test case can take minutes or even hours with inefficient approach.

So, you need to learn new concepts to make your code time efficient.


you should particularly give focus on question understanding and try to implement your solution with that question with absolute time complexity u can reduce .In last ur this step will make your code efficient and might endup your problem

Sometimes partially accepted codes get accepted for 100 by writing only one line


std::ios::sync_ with_ stdio(false); // add this inside main() function as the first line of main()

Otherwise that question can be done by some standard algorithm or you need to make your code more efficient

which can be done by keen observation or instead of Brute Force You should derive some pattern or formula for

that problem

Thanks,I hope it helps.