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

weak tests
Posted by Pavel Tolstikov 12 Oct 2007 22:15
I got AC.
My solution uses simple stack with 15 elements in each node. System memory management functions have some memory overhead, so I take mem from static 512k heap. Memory freeing wasn't realized. When some POPs make node empty memory leaks. And next PUSH will alloc new node. Many POP-PUSH crash my programm.

Here is example of such test
#include <stdio.h>
int main()
{
printf ("40015\n");
int i;
for (i=0;i<15;++i)
printf ("PUSH 1 %d\n", i+1);  // full 1 node
for (i=0;i<10000;++i)
printf ("PUSH 1 %d\nPOP 1\nPOP 1\nPUSH 1 %d\n", i+1,i+100000);
return 0;
}