結果
問題 |
No.1765 While Shining
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:33:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 82,100 KB |
実行使用メモリ | 101,340 KB |
最終ジャッジ日時 | 2025-03-20 20:34:53 |
合計ジャッジ時間 | 2,911 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)