ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2018. The Debut Album

Python3 TLE 4 test
Posted by Desserg 12 Dec 2019 15:41
if test 50000 300 300
My solution takes about 1.9 seconds (time library). the test fails.

almost all the time spent on summarizing lists:

"ncalls  tottime  percall  cumtime  percall filename:lineno(function)"
"99402    1.773    0.000    1.773    0.000  {built-in method builtins.sum}"

Maybe there is a way to more quickly summarize than the built-in function "sum"?

Edited by author 12.12.2019 15:42

Edited by author 12.12.2019 15:42

Edited by author 12.12.2019 15:42
Re: Python3 TLE 4 test
Posted by Viktor Sergeev 10 Jan 2020 16:34
You may recalculate total sum of list on every iteration, if that lists changes predictable for you. For example, if you shift you list to the left for one position, and add some other value, then you may substract that shifted value and add new one, thus you perform updation.