Reading array of integers readln performance issues

kerdemdemir via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 11 12:55:59 PDT 2015


Hi;

To learn D better and challanging myself I am tring code 
computation's with D.

There is a question which is about reading a line of integer 
which consist of 200000 elements.

My solution fails because "Time limit exceeded", I thought it is 
because of my algorithm first. I realize time limit is exceeded 
even before my algorithm starts while reading line of integers. I 
understand this by giving a wrong answer to question after readln 
statement. I did that to get a "wrong answer error" but my code 
still get a "Time limit exceed" error because "readln" takes very 
long time.

Can I achieve something faster than code below?

auto peopleMoney = stdin.readln().split().map!(a => 
to!int(a)).array();
if (peopleMoney.length == 200000)
	 writeln(":(");

Regards
Erdem


Ps: I do not want to bore you with long code, but I am sending 
link to whole program anyway if anyone need.
  http://codeforces.com/contest/549/submission/11537206


More information about the Digitalmars-d-learn mailing list