提出 #47785313


ソースコード 拡げる

#ABC329C

from collections import defaultdict as dd

#入力受取
N=int(input()); S=input()

#ランレングス圧縮
S+='#'  #Sの末尾に番兵を置く
RLE = []; Lt = 0
for Rt in range(N):
  if S[Rt] != S[Rt+1]:
    RLE.append((S[Rt], Rt+1-Lt))
    Lt = Rt+1
    
#各成分ごとの最長を調べる
D=dd(int)
for e,c in RLE: D[e]=max(D[e],c)

#答えを出力
ans=0
for e in D: ans+=D[e]
print(ans)

提出情報

提出日時
問題 C - Count xxx
ユーザ navel_tos
言語 Python (PyPy 3.10-v7.3.12)
得点 300
コード長 431 Byte
結果 AC
実行時間 104 ms
メモリ 99408 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 20
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 73 ms 76232 KiB
00_sample_01.txt AC 74 ms 76484 KiB
00_sample_02.txt AC 72 ms 76360 KiB
01_random_00.txt AC 81 ms 81024 KiB
01_random_01.txt AC 77 ms 81224 KiB
01_random_02.txt AC 104 ms 97604 KiB
01_random_03.txt AC 100 ms 99408 KiB
01_random_04.txt AC 76 ms 80836 KiB
01_random_05.txt AC 92 ms 91540 KiB
01_random_06.txt AC 89 ms 91036 KiB
01_random_07.txt AC 89 ms 89256 KiB
01_random_08.txt AC 81 ms 83940 KiB
01_random_09.txt AC 101 ms 97372 KiB
01_random_10.txt AC 78 ms 80780 KiB
01_random_11.txt AC 76 ms 81352 KiB
01_random_12.txt AC 76 ms 81760 KiB
01_random_13.txt AC 76 ms 81276 KiB
02_handmade_00.txt AC 76 ms 81420 KiB
02_handmade_01.txt AC 99 ms 99236 KiB
02_handmade_02.txt AC 77 ms 81512 KiB