結果

問題 No.1765 While Shining
ユーザー 炭酸水炭酸水
提出日時 2022-05-17 20:10:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 775 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 13,632 KB
最終ジャッジ日時 2023-10-13 19:45:33
合計ジャッジ時間 5,896 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,904 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 16 ms
7,760 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 WA -
testcase_05 AC 17 ms
7,848 KB
testcase_06 AC 16 ms
7,908 KB
testcase_07 AC 16 ms
7,840 KB
testcase_08 AC 17 ms
7,912 KB
testcase_09 AC 147 ms
10,408 KB
testcase_10 AC 203 ms
11,284 KB
testcase_11 AC 178 ms
10,848 KB
testcase_12 AC 198 ms
11,032 KB
testcase_13 AC 179 ms
11,192 KB
testcase_14 AC 219 ms
11,980 KB
testcase_15 AC 217 ms
11,968 KB
testcase_16 AC 218 ms
12,000 KB
testcase_17 AC 220 ms
11,916 KB
testcase_18 AC 220 ms
11,884 KB
testcase_19 AC 217 ms
11,856 KB
testcase_20 AC 215 ms
11,860 KB
testcase_21 AC 220 ms
11,924 KB
testcase_22 WA -
testcase_23 AC 214 ms
11,992 KB
testcase_24 AC 232 ms
13,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0