結果

問題 No.2035 Tunnel
ユーザー 👑 KazunKazun
提出日時 2022-08-12 21:43:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 75,264 KB
最終ジャッジ日時 2023-10-24 09:08:35
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,516 KB
testcase_01 AC 38 ms
53,516 KB
testcase_02 AC 38 ms
53,516 KB
testcase_03 AC 38 ms
53,516 KB
testcase_04 AC 39 ms
53,516 KB
testcase_05 AC 56 ms
75,240 KB
testcase_06 AC 57 ms
75,240 KB
testcase_07 AC 56 ms
75,264 KB
testcase_08 AC 53 ms
75,236 KB
testcase_09 AC 53 ms
75,232 KB
testcase_10 AC 54 ms
75,124 KB
testcase_11 AC 55 ms
72,052 KB
testcase_12 AC 60 ms
75,056 KB
testcase_13 AC 46 ms
62,172 KB
testcase_14 AC 47 ms
64,976 KB
testcase_15 AC 57 ms
74,448 KB
testcase_16 AC 52 ms
69,176 KB
testcase_17 AC 44 ms
59,672 KB
testcase_18 AC 44 ms
60,008 KB
testcase_19 AC 48 ms
65,264 KB
testcase_20 AC 55 ms
72,112 KB
testcase_21 AC 47 ms
65,496 KB
testcase_22 AC 48 ms
65,552 KB
testcase_23 AC 43 ms
62,388 KB
testcase_24 AC 48 ms
66,452 KB
testcase_25 AC 50 ms
69,256 KB
testcase_26 AC 50 ms
69,004 KB
testcase_27 AC 55 ms
74,640 KB
testcase_28 AC 47 ms
65,664 KB
testcase_29 AC 44 ms
62,424 KB
testcase_30 AC 43 ms
60,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Run_Length_Encoding(S):
    """ランレングス圧縮

    S:文字列
    """
    if not S:
        return []

    R=[[S[0],1]]

    for i in range(1,len(S)):
        if R[-1][0]==S[i]:
            R[-1][1]+=1
        else:
            R.append([S[i],1])

    return R
#==================================================
N=int(input())
S=list(input())

a=0
ans=0
for i in range(N-1,-1,-1):
    if S[i]=="#":
        a+=1
        ans=N-1-i+a
    else:
        a=max(a-1,0)

print(ans)
0