this is my code.
all the test cases are working fine.
getting tle while submitting on spoj because i need memo pad of more than 10^6.
what should i do to get the right ans.
this the link of the code
this is my code.
all the test cases are working fine.
getting tle while submitting on spoj because i need memo pad of more than 10^6.
what should i do to get the right ans.
this the link of the code
You can delare dp as global array and precompute the result for all n upto 3*10^7. And then you will be able to answer the query in O(1) time .
https://ide.codingblocks.com/#/s/20019
Does the size of global array is greater than locally declared array ?
like locally declared array can have maximum of 10^6 elements.