why does recursive code fail for some test cases ?

Правка en4, от anipnwr, 2021-04-29 12:22:25

Hi!

I was trying the Atcoder educational DP contest and I wrote a recursive DP solution for problem A . It works fine for 7 test cases but fails for last 4.

The point that is disturbing me is that, similar logic but iterative code of DP is getting accepted for other people.

Can someone please help me with this or point out my mistake if I am doing a foolish one. Thanks in advance.

This is my code

This is the iterative code that works

ALSO, ONE MORE DOUBT. I DOWNLOADED THE TEST CASE, IT HAD SOME 99000 VALUES IN ARRAY. THE CODE JUST DIDN'T GIVE ANY OUTPUT IN SUBLIME TEXT. I TRIED SOME ONLINE COMPILERS THEY ALSO HAD A INPUT SIZE RESTRICTION. SO IT ALSO DIDN'T WORK. MY QUESTION IS, IS IT SOME RESTRICTION THAT WINDOWS OS HAS INBUILT OR IT IS SOME OTHER ISSUE?

Теги # dp, #recursion,dp

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский anipnwr 2021-04-29 12:24:45 0 (published)
en6 Английский anipnwr 2021-04-29 12:23:26 2 Tiny change: 'sh one. \nThis is ' -> 'sh one. \n\nThis is '
en5 Английский anipnwr 2021-04-29 12:23:10 44
en4 Английский anipnwr 2021-04-29 12:22:25 5
en3 Английский anipnwr 2021-04-29 12:18:29 351
en2 Английский anipnwr 2021-04-29 12:12:27 45
en1 Английский anipnwr 2021-04-29 12:10:12 659 Initial revision (saved to drafts)