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

Common Board

Help me!!!!!
Posted by RAVEman 1 Oct 2004 16:41
Tell me please why I got Memory Limit Exeeded.

// problem 1100

#include<stdio.h>

long id[150001L];
int m[150001L];
long pr[101],i,j,n;

int main()
{
    scanf("%ld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%ld %d",&id[i],&m[i]);
        pr[m[i]]++;
    }
    for(i=100;i>=0;i--)
    {
        j=1;
        while(pr[i]!=0)
        {
            if(m[j]==i)
            {
                printf("%ld %d\n",id[j],m[j]);
                pr[i]--;
            }
            j++;
        }
    }
    return 0;
}
Because your prog use 150000*(4+2)=900K memory. The more-than-200K memory used by the compiler included, you get MLE.
In fact, if you use C, you can use only a bit more than 700KB. For Pascalers, there's only 627KB.
Your prog use 150000*(4+4)=1200K of memory, sizeof(int)==4. (-)
Posted by Problemset Maintainer 3 Oct 2004 01:18