結果
問題 | No.1765 While Shining |
ユーザー |
![]() |
提出日時 | 2025-03-20 18:51:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 82,496 KB |
実行使用メモリ | 101,080 KB |
最終ジャッジ日時 | 2025-03-20 18:52:43 |
合計ジャッジ時間 | 2,596 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
N = int(input()) A = list(map(int, input().split())) A = [0] + A # Convert to 1-based indexing current_rev0 = 0 current_rev1 = 0 total = 0 for i in range(N, 0, -1): if i == N: new_rev0 = 0 new_rev1 = 0 else: a = A[i] if a == 1: new_rev0 = 1 + current_rev1 else: new_rev0 = 0 if a == 0: new_rev1 = 1 + current_rev0 else: new_rev1 = 0 current_rev0, current_rev1 = new_rev0, new_rev1 total += current_rev0 print(total)