10491 - Cows and Cars

All about problems in Volume 104. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

johannoren
New poster
Posts: 3
Joined: Thu Apr 10, 2014 10:54 am

Re: 10491 - Cows and Cars

Post by johannoren » Thu Apr 10, 2014 11:02 am

My solution is correct for the test data and it should be efficient. O(1) with some simple calculations. Still I get TLE??
My solution is in Java and I read until EOF so it shouldn't wait for more input I think.

Is the number of test cases extremely large or what am I missing?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10491 - Cows and Cars

Post by brianfry713 » Thu Apr 10, 2014 8:53 pm

Try using BufferedReader and BufferedWriter, or post your code. Someone recently solved it using Java.
Check input and AC output for thousands of problems on uDebug!

johannoren
New poster
Posts: 3
Joined: Thu Apr 10, 2014 10:54 am

Re: 10491 - Cows and Cars

Post by johannoren » Thu Apr 10, 2014 10:34 pm

Thanks Brian. I used BufferedReader already and buffered output in a StringBuilder before printing everything in a chunk.
Tried again now with a minor change and got AC. Maybe some misfortuned garbage collection or something I haven't understood that TLE'd last time. Anyhow, thnx.

Post Reply

Return to “Volume 104 (10400-10499)”