結果

問題 No.1765 While Shining
ユーザー ThetaTheta
提出日時 2022-10-24 19:32:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 711 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 11,512 KB
最終ジャッジ日時 2023-09-15 21:07:36
合計ジャッジ時間 4,022 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,896 KB
testcase_01 AC 17 ms
7,832 KB
testcase_02 AC 17 ms
7,848 KB
testcase_03 AC 17 ms
7,908 KB
testcase_04 AC 18 ms
7,840 KB
testcase_05 AC 17 ms
7,904 KB
testcase_06 AC 16 ms
7,948 KB
testcase_07 AC 17 ms
7,800 KB
testcase_08 AC 17 ms
7,812 KB
testcase_09 AC 100 ms
10,248 KB
testcase_10 AC 140 ms
11,312 KB
testcase_11 AC 125 ms
10,936 KB
testcase_12 AC 130 ms
11,028 KB
testcase_13 AC 122 ms
11,220 KB
testcase_14 AC 153 ms
11,312 KB
testcase_15 AC 151 ms
11,248 KB
testcase_16 AC 152 ms
11,312 KB
testcase_17 AC 152 ms
11,372 KB
testcase_18 AC 148 ms
11,508 KB
testcase_19 AC 148 ms
11,300 KB
testcase_20 AC 147 ms
11,444 KB
testcase_21 AC 147 ms
11,388 KB
testcase_22 AC 150 ms
11,496 KB
testcase_23 AC 149 ms
11,312 KB
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

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