結果
問題 | No.1765 While Shining |
ユーザー | kys |
提出日時 | 2021-11-26 23:02:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 369 ms |
コンパイル使用メモリ | 86,896 KB |
実行使用メモリ | 117,432 KB |
最終ジャッジ日時 | 2023-09-12 05:27:16 |
合計ジャッジ時間 | 4,418 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 78 ms
71,180 KB |
testcase_01 | AC | 80 ms
71,312 KB |
testcase_02 | AC | 78 ms
71,140 KB |
testcase_03 | AC | 79 ms
71,216 KB |
testcase_04 | AC | 80 ms
71,152 KB |
testcase_05 | AC | 79 ms
71,504 KB |
testcase_06 | AC | 79 ms
71,008 KB |
testcase_07 | AC | 80 ms
71,252 KB |
testcase_08 | AC | 78 ms
71,120 KB |
testcase_09 | AC | 113 ms
92,936 KB |
testcase_10 | AC | 127 ms
104,328 KB |
testcase_11 | AC | 120 ms
98,196 KB |
testcase_12 | AC | 126 ms
101,140 KB |
testcase_13 | AC | 119 ms
98,420 KB |
testcase_14 | AC | 128 ms
104,284 KB |
testcase_15 | AC | 122 ms
104,488 KB |
testcase_16 | AC | 129 ms
104,412 KB |
testcase_17 | AC | 125 ms
104,568 KB |
testcase_18 | AC | 123 ms
104,636 KB |
testcase_19 | AC | 126 ms
104,252 KB |
testcase_20 | AC | 129 ms
104,512 KB |
testcase_21 | AC | 127 ms
104,288 KB |
testcase_22 | AC | 128 ms
104,556 KB |
testcase_23 | AC | 127 ms
104,408 KB |
testcase_24 | AC | 127 ms
117,432 KB |
ソースコード
import sys input = sys.stdin.readline def iinput(): return int(input()) def sinput(): return input().rstrip() def i0input(): return int(input()) - 1 def linput(): return list(input().split()) def liinput(): return list(map(int, input().split())) def miinput(): return map(int, input().split()) def li0input(): return list(map(lambda x: int(x) - 1, input().split())) def mi0input(): return map(lambda x: int(x) - 1, input().split()) INF = 10**20 MOD = 1000000007 N = iinput() A = liinput() ans = 0 tmp = [] for i, a in enumerate(A): if tmp == []: if a == 1: tmp.append(a) else: if a != tmp[-1]: tmp.append(a) else: if tmp[0] == 1: l = len(tmp) ll = l // 2 ans += ll * (ll + 1) + (l % 2) * (ll + 1) if a == 0: tmp = [] else: tmp = [a] if tmp: _ = tmp.pop() l = len(tmp) ll = l // 2 ans += ll * (ll + 1) + (l % 2) * (ll + 1) print(ans)