pages:
  • 1
  • 2
Sadjad U - Sajjad SAYS

salam doostan mamnoon misham javabam ro bedin :X 1- in soal UNTILE EOF e ? 2- age n=1 bashe bayad jolly chap she? 3- ekhtelaf ha hatman bayad be soorate nozooly! bashe ya farghy nemikone?

BECCA SAYS

Sadjad U - Sajjad said:

salam doostan mamnoon misham javabam ro bedin :X 1- in soal UNTILE EOF e ? 2- age n=1 bashe bayad jolly chap she? 3- ekhtelaf ha hatman bayad be soorate nozooly! bashe ya farghy nemikone?

1) Yes. 2) Yes! 3) No. It doesn't matter. 1 2 5 3 7 is Jolly.

farshad SAYS

doostan age mishe in soal ro qashang toozih bedin ke chetori hast mamnoon misham

AMiR SAYS

farshad said:

doostan age mishe in soal ro qashang toozih bedin ke chetori hast mamnoon misham

In the problem statement clearly states

A sequence of n > 0 integers is called a jolly jumper if the absolute values of the difference between successive elements take on all the values 1 through n-1.

Which part is not clear to you so we can explain it more?

farshad SAYS

no thanks amir

farshad SAYS

should the elements be different or not? can be 4 1 2 1 3?

AMiR SAYS

farshad said:

should the elements be different or not? can be 4 1 2 1 3?

If something is not clearly mentioned in the problem specification, you must consider it may happen.

So in this case, the answer is there may be equal numbers in some test cases, and there may be not in some other tests.

AMiR SAYS

farshad said:

should the elements be different or not? can be 4 1 2 1 3?

Another thing that you should note is it is better to test your codes on your own machine this way:

g++ code.cpp -O2 -o solution
./solution < test_input

and compare the output with the sample output. This way you can make sure you are resetting all the variables for each test-case.

Another important thing is you have to read the problem constraints carefuly and adjust the size of your variables and arrays according to them.

farshad SAYS

my code output the right answer but when i submit it , gets runtime error why?

AMiR SAYS

farshad said:

my code output the right answer but when i submit it , gets runtime error why?

You should read the constraints of the problem more carefuly!

You can write a code to generate critical test cases, for the maximum n and minimum n ...