結果
問題 | No.1765 While Shining |
ユーザー | 炭酸水 |
提出日時 | 2022-05-17 20:33:57 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 241 ms / 2,000 ms |
コード長 | 786 bytes |
コンパイル時間 | 530 ms |
コンパイル使用メモリ | 10,872 KB |
実行使用メモリ | 13,488 KB |
最終ジャッジ日時 | 2023-10-13 20:11:28 |
合計ジャッジ時間 | 5,537 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,792 KB |
testcase_01 | AC | 17 ms
7,780 KB |
testcase_02 | AC | 16 ms
7,824 KB |
testcase_03 | AC | 15 ms
7,928 KB |
testcase_04 | AC | 16 ms
7,796 KB |
testcase_05 | AC | 16 ms
7,804 KB |
testcase_06 | AC | 16 ms
7,828 KB |
testcase_07 | AC | 16 ms
7,812 KB |
testcase_08 | AC | 17 ms
7,856 KB |
testcase_09 | AC | 148 ms
10,256 KB |
testcase_10 | AC | 206 ms
11,396 KB |
testcase_11 | AC | 178 ms
10,872 KB |
testcase_12 | AC | 195 ms
11,000 KB |
testcase_13 | AC | 177 ms
11,192 KB |
testcase_14 | AC | 217 ms
12,008 KB |
testcase_15 | AC | 221 ms
11,896 KB |
testcase_16 | AC | 216 ms
11,892 KB |
testcase_17 | AC | 214 ms
11,956 KB |
testcase_18 | AC | 217 ms
11,844 KB |
testcase_19 | AC | 219 ms
11,884 KB |
testcase_20 | AC | 220 ms
12,000 KB |
testcase_21 | AC | 217 ms
11,880 KB |
testcase_22 | AC | 222 ms
11,908 KB |
testcase_23 | AC | 220 ms
11,932 KB |
testcase_24 | AC | 241 ms
13,488 KB |
ソースコード
n = int(input()) a = list(map(int, input().split())) L = 0 while a[L] == 0 and L < n: L += 1 if L == n: print(0) else: R = L while L < n - 1: count = 0 while R < n - 1 and a[R] != a[R + 1]: R += 1 count += 1 if R == n - 1 and count >= 1: count -= 1 a[L] += count while L < R - 1: L += 1 count -= 1 if a[L] == 1: a[L] += count if L == R: L += 1 R = L elif a[R] == 0: while R < n - 1 and a[R] == 0: R += 1 L = R elif a[R] == 1: L = R a[n - 1] = 0 ans = 0 for i in a: ans += i print(ans)