Kayaks - Runtime Error C++

I tried my best to optimize it.
But, it still shows runtime error.
Please help.

My Code Link:

You don’t need optimizations to get rid of the current error. You are getting a Rumtime error SIGSEGV. See the reasons why you could get a SIGSEGV http://www.codechef.com/wiki/faq#Why_do_I_get_a_SIGSEGV.

		cin>>a[i][1];//w	Strength

In the lines above you are accessing the array elements a[i][0], a[i][1] and i could be as large as n and n<=10^5. But your array declaration is just a[10][3] hence you will end up making some invalid memory access after i crosses 10 resulting in a SIGSEGV.

1 Like