結果

問題 No.1765 While Shining
ユーザー Theta
提出日時 2022-10-24 19:32:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 711 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,784 KB
最終ジャッジ日時 2024-07-02 22:36:41
合計ジャッジ時間 4,970 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

class Board:
    def __init__(self, board: list[int]) -> None:
        self.board = board

    def calc_move_times(self, mass: int, is_shine: bool) -> int:
        if mass == len(self.board) - 1:
            return 0

        if not is_shine:
            return 0

        if self.board[mass] == is_shine:
            return 1 + self.calc_move_times(mass+1, not self.board[mass+1])
        else:
            return 1 + self.calc_move_times(mass+1, self.board[mass+1])


def main():
    N = int(input())
    A = list(map(int, input().split()))
    board = Board(A)
    print(sum(map(lambda arg: board.calc_move_times(arg[0], arg[1]),
                  zip(range(N), A))))


if __name__ == "__main__":
    main()
0