def better_bottom_up_mscs(seq: list) -> tuple:
    """Returns a tuple of three elements (sum, start, end), where sum is the sum
    of the maximum contiguous subsequence, and start and end are respectively
    the starting and ending indices of the subsequence.

    Let sum[k] denote the max contiguous sequence ending at k. Then, we have

        sum[0] = seq[0]

        sum[k + 1] = max(seq[k], sum[k] + seq[k]).

    To keep track where the max contiguous subsequence starts, we use a list.

    Time complexity: O(n).

    Space complexity: O(1)."""
    _max = seq[0]
    _sum = seq[0]
    index = 0

    start = end = 0

    for i in range(1, len(seq)):

        if _sum > 0:
            _sum = _sum + seq[i]
        else:
            _sum = seq[i]
            index = i

        if _sum > _max:
            _max = _sum
            end = i
            start = index

    return _max, start, end