|
|
back to boardPlease ! Need help..my algoritm is wright, but ! WA9 > > i found my mistake Edited by author 20.11.2005 00:44 Re: Please ! Need help..my algoritm is wright, but ! WA9 I have wa#9 but I can't found mistake :( what is test 9? Re: Please ! Need help..my algoritm is wright, but ! WA9 Posted by Temur 3 Dec 2015 09:58 3 -1 -1 1 try this Re: Please ! Need help..my algoritm is wright, but ! WA9 I tried this and I get the correct answer, but test 9 code fails. Re: Please ! Need help..my algoritm is wright, but ! WA9 Here is the code that fails test 9: from typing import List potentials: List[int] = [] N: int = int(input()) for p in range(N): potentials.append(int(input())) def list_max_right_sum(lst: List[int]) -> List[int]: amount: int = 0 left_min: int = 0 left_max_index: int = 0 k: int = 0 for i, p in enumerate(lst): amount += p k = i + 1 if amount < left_min: left_min = amount left_max_index = i + 1 return lst[left_max_index: k] result: List[int] = list_max_right_sum(potentials) result.reverse() result = list_max_right_sum(result) print(sum(result)) |
|
|