Painter problem

answer is coming correct but showing runtime error. I can’t find any errors in it.

https://ide.codingblocks.com/s/44588

I dont have link to the question. its in sorting challenges. it is quite similar to this question.
https://hack.codingblocks.com/contests/c/452/716

Hey, as the constraints are large in this problem so, when you are adding all the elements of the array it will cross the range of long long int, So perform the modular operation with %10000003 when you are adding or multiplying the numbers. If you don’t know how to use modulo you can refer to number theory section videos of your online course.

Apart from that in your first line of main() ll n=0,k=0,t=0,len[n],ttl_len=0; here you initialised the array len with size n and n=0, you can’t do that… you can’t initialise an array with size 0. If you want to give the size of the array on compile time give it the max value of N possible i.e 100001 and if you want to give the size of array at run time you can initialize it like this ll* arr= new ll[n];

Thank you so much. It was of great help :smiley:

No problem keep coding and raising doubts :slight_smile: