|
|
back to boardCommon BoardHelp me!!!!! 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. (-) |
|
|