AtCoder-Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub ryusuke920/AtCoder-Library

:heavy_check_mark: Math/MaxCumulativeSum.py

Verified with

Code

def MaxCumulativeSum(num_array: list, k: int):
    max_cumulative_sum = []
    count = 0
    for i in range(k):
       count += num_array[i]
    max_cumulative_sum.append([count, 0, 0 + k])
 
    for i in range(len(num_array) - k):
        count += num_array[i + k]
        count -= num_array[i]
        max_cumulative_sum.append([count, i + 1, i + 1 + k])
    
    max_cumulative_sum.sort(key = lambda x: x[0], reverse=True)
    return max_cumulative_sum[0]


def main() -> None:
    a = [1, 4, -1, 9, 34, 21, -12, 31]
    ans = MaxCumulativeSum(a, 3) # 配列・区間幅
    print(ans)


if __name__ == "__main__":
    main()
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page