Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Автор magma1983, 8 лет назад, По-английски

I solved the same problem in two different programming languages: Java and Python. The Java program is usually longer in terms of LOCs, it uses more memory and his time execution is slower than Python code. As we can see in the next screenshot:

Python seems to be a better choice, however, Java is still widely used.

  • Проголосовать: нравится
  • -38
  • Проголосовать: не нравится

»
8 лет назад, # |
Rev. 5   Проголосовать: нравится +12 Проголосовать: не нравится

You are using Scanner to read input in Java. That's why it is very slow, and it's why almost no one uses it in Programming Competitions. Similar things like using strings, and not knowing the complexity of "+" operator can make Java programs very slow.

No Python is not a better option for Competitive Programming in terms of speed. It's very well known, I can get you many problems where getting AC with python is impossible ( due to speed).

Maybe there exists a certain application where Python is faster, but generally no.