Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя ankitdipto

Автор ankitdipto, история, 4 года назад, По-английски

I am unable to understand why declaring an array dp[71][1<<20] results in MEMORY LIMIT EXCEEDED in the code. As far as the problem definition is concerned I only need 19 bits (there are 19 prime numbers less than 70) hence the problem can be solved by using array of size dp[71][1<<19]. Using the latter I have indeed got AC but I don't know why my code is taking too much memory in general.

Link to the problem

Here goes my code: 93536513

Since I am posting for the first time I beg pardon for the ill formatting!

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

int = $$$4$$$ bytes

$$$2 ^ {20}$$$ * $$$71$$$ integers = $$$297795584$$$ bytes

$$$297795584$$$ bytes = $$$290816$$$ kylobytes

$$$290816$$$ kylobytes = $$$284$$$ megabytes

You are using $$$284$$$ megabytes, but in problem requirement is at maximum $$$256$$$ megabyte, and when you take array of size $$$2 ^ {19}$$$ * $$$71$$$, you are using $$$284 / 2$$$ = $$$142$$$ megabytes which fits in requirements