CarViz's blog

By CarViz, history, 29 hours ago, In English

hello all

will delete next period

can you guys figure out why im runtime erroring

391906583

thanks,

edit: i didnt generate enough primes whoops.

  • Vote: I like it
  • +17
  • Vote: I do not like it

»
29 hours ago, hide # |
← Rev. 2  
Vote: I like it +8 Vote: I do not like it

first time seeing normal blog by CarViz

  • »
    »
    21 hour(s) ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    A normal blog by Carviz before GTA6?

»
29 hours ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Auto comment: topic has been updated by CarViz (previous revision, new revision, compare).

»
29 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I think the runtime error is most likely caused by this line:

while (i+1)*primel[lp]-1 < len(l):

You access primel[lp] before checking whether lp is still within the bounds of primel. If lp becomes equal to len(primel), this causes an IndexError: list index out of range.

Also, this line can cause an IndexError if any value in l is greater than len(l):

sum([dp[i-1] for i in l])

For example, if len(l) = 3 but l contains 100, then dp[99] is out of bounds.

You should check the constraints and make sure the prime list is large enough, and also verify that every value in l is a valid index for dp.

»
28 hours ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

will delete next period

I guess he learned how to pocket solve

»
26 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I didn't even notice that this was DP during the entire contest :(. I just assumed you can greedily take the lowest power like a noob. Wrong answered test 6.