Why is Python faster than C++ in this example?

Правка en3, от s3yoonpark, 2023-04-30 22:53:51

So I am solving question 3 from here https://www.olympiad.org.uk/papers/2016/bio/bio16-exam.pdf

I have two pieces of code, one in Python and one in C++. (Both attached below as pictures)

Although the both pieces of code seem to be employing the same logic, the Python one seems to be a lot faster than C++.

An example test case could be -> 614700 3643 90149 -> (It should output 18)

Please can someone tell me why this is the case?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский s3yoonpark 2023-04-30 22:58:42 92 (published)
en3 Английский s3yoonpark 2023-04-30 22:53:51 0 Added Images (saved to drafts)
en2 Английский s3yoonpark 2023-04-30 22:49:17 1
en1 Английский s3yoonpark 2023-04-30 22:48:49 503 Initial revision (published)