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

ML10 - 0.9mb
Posted by Rayzor 8 Nov 2009 15:14
I tryed to minimize using of memory, but...


#include <cstdio>
#include <stack>
#include <map>

using namespace std;

map<unsigned int,stack<unsigned int> > m;

unsigned int n, i, b;
unsigned short a;
char c;


void main(void)
{
    scanf("%d",&n);

    for(i=0;i<n;i++){

        scanf("%s%s",c,c);

        if (c == 'U'){
            scanf("%d %d\n",&a,&b);
            m[a].push(b);
        }else{
            scanf("%d\n",&a);
            printf("%d\n",m[a].top());
            m[a].pop();
        }
    }
}
Re: ML10 - 0.9mb
Posted by Varun Sharma 18 Nov 2009 02:33
Hi,

Don't use Maps and Stacks. They take too much memory. You need to try to solve this problem by just including <cstdio> library and nothing else.

However, I still can't do it even though I am doing that and using dynamic arrays. I am getting MLE 12.

Varun