You are not logged in. Please login at www.codechef.com to post your questions!

×

Kayaks - Runtime Error C++

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

My Code Link: http://www.codechef.com/viewsolution/1126929

asked 14 Jun '12, 11:45

vaibhav6980's gravatar image

2★vaibhav6980
1111
accept rate: 0%

edited 25 Jun '12, 13:01

admin's gravatar image

0★admin ♦♦
19.0k348495531


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.

    for(i=0;i<n;i++)
    {
        a[i][0]=i;
        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.

link

answered 14 Jun '12, 12:01

gultus's gravatar image

4★gultus ♦
1.5k11325
accept rate: 51%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,745
×401
×51
×32
×2

question asked: 14 Jun '12, 11:45

question was seen: 1,421 times

last updated: 25 Jun '12, 13:01