### beginner1010's blog

By beginner1010, history, 9 days ago, ,

Today, I tried problem G from Education Round 45. My java implementation (64550159) gets time limit exceeded. It takes at least 4500 ms on test 5 while the same C++ implementation (64545259) on that test case takes only 600 ms.

I tried different things to optimize the Java implementation, but none could help. I believe there is something tricky that I am missing. I appreciate if you let me know which part of my Java implementation affects the overall performance.

BTW, in the C++ implementation, I used an array instead of queue<int>. I found queue so slow which causes time limit exceeded.

• +13

 » 9 days ago, # |   +9 64553387ArrayList sucks, boxing/unboxing also sucks, so sometimes you have to use something like /blog/entry/14328 or just primitive int arrays. Yeah, I know it's a bit ridiculous.
•  » » 9 days ago, # ^ |   0 Thanks a lot for providing the link to the blog. I was searching for similar thing for days.
•  » » 9 days ago, # ^ | ← Rev. 2 →   0 Very interesting. I might need to make something like this in Kotlin one of these daysEdit: One slight issue is that one of Kotlin's blessings, the extensive collection-manipulation library, becomes somewhat of a curse when rolling your own specialized collections. I find I'd basically have to rewrite what I need on the fly.