ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1220. Stacks

a silly problem
Posted by FireHeart 18 Jun 2007 09:42
I define :
type PNODE=^NODE
      NODE=record
       value:longword; pre:PNODE; end
Var A:array[1..1000] of PNODE;
then memory used is 1064KB
 but when add :
type PNODE=^NODE
      NODE=record
       value:longword; pre:PNODE; end
Var A:array[1..1000] of PNODE;
    last:array[1..1000] of PNODE;
then memory used is 932KB
---> what happend ??
Re: a silly problem
Posted by N.M.Hieu ( DHSP ) 18 Jun 2007 14:07
Depend on the way you use the array.
The memory is not only the memory you declare in your program but also the memory to run your program.
Memory = memory you declare + memory to run your program .
Re: a silly problem
Posted by FireHeart 18 Jun 2007 16:18
In Vietnamese : Làm sao tính được vậy anh, em đã loại hết tất cả những gì có thể bỏ được rồi. Vẫn bị MLE
Re: a silly problem
Posted by Alias (Alexander Prudaev) 19 Jun 2007 02:40
it is not a necessary to allocate memory for all memory that
you declare(but for memory that you use it is necessary)
memory can allocates by blocks, and only if you use it

algorithm that rule this process can depends on total memory that you declare and it is possible that in this
situation compiler uses such algorithm
Re: a silly problem
Posted by N.M.Hieu ( DHSP ) 19 Jun 2007 17:33
In Vietnamese :
Vì 1 con trỏ của em tốn tới 8 byte ( 4 byte cho longword và 4 byte cho việc "trỏ" ) -> N <= 100000 thì em đã mất tới 800000 byte > 0.75 MB rồi . MLE là điều tất yếu .
Anh dùng mảng , kô dùng con trỏ cũng mất tới 700 KB :) .

Edited by author 19.06.2007 17:34