Блог пользователя beginner1010

Автор beginner1010, история, 7 лет назад, По-английски

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
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

64553387
ArrayList 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.