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 1438. Time Limit Exceeded

Finally AC && Slow C++ memory allocation
Posted by diver[rus] 20 Feb 2007 23:10
First i read whole file line-by-line in single string s.
And my program got TLE11 many times.
But when i wrote a single line:
   s.reserve(2000000);
before reading of file, my program got AC 0.343.
So if you want avoid TLE in similar problems, reserve memory beforehand (if it possible) when you using STL.

Edited by author 21.02.2007 01:20
Re: Finally AC && Slow C++ memory allocation
Posted by Denis Koshman 24 Aug 2008 05:47
If you want predictable timing and memory allocation, avoid using STL at all