結果

問題 No.1924 3 color painting on a line
ユーザー tassei903tassei903
提出日時 2022-04-28 00:26:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 80,588 KB
最終ジャッジ日時 2023-09-14 15:16:30
合計ジャッジ時間 6,904 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,400 KB
testcase_01 AC 72 ms
71,472 KB
testcase_02 AC 71 ms
71,340 KB
testcase_03 AC 94 ms
80,320 KB
testcase_04 AC 89 ms
80,348 KB
testcase_05 AC 89 ms
80,524 KB
testcase_06 AC 88 ms
80,488 KB
testcase_07 AC 90 ms
80,452 KB
testcase_08 AC 91 ms
80,500 KB
testcase_09 AC 90 ms
80,400 KB
testcase_10 AC 88 ms
80,384 KB
testcase_11 AC 90 ms
80,440 KB
testcase_12 AC 89 ms
80,124 KB
testcase_13 AC 89 ms
80,508 KB
testcase_14 AC 89 ms
80,588 KB
testcase_15 AC 86 ms
80,424 KB
testcase_16 AC 91 ms
80,152 KB
testcase_17 AC 91 ms
80,504 KB
testcase_18 AC 91 ms
80,312 KB
testcase_19 AC 92 ms
80,360 KB
testcase_20 AC 86 ms
80,212 KB
testcase_21 AC 90 ms
80,520 KB
testcase_22 AC 93 ms
80,228 KB
testcase_23 AC 85 ms
77,088 KB
testcase_24 AC 89 ms
79,992 KB
testcase_25 AC 88 ms
78,608 KB
testcase_26 AC 79 ms
76,436 KB
testcase_27 AC 87 ms
78,004 KB
testcase_28 AC 86 ms
77,112 KB
testcase_29 AC 83 ms
76,372 KB
testcase_30 AC 84 ms
76,236 KB
testcase_31 AC 84 ms
76,264 KB
testcase_32 AC 89 ms
78,940 KB
testcase_33 AC 87 ms
78,356 KB
testcase_34 AC 88 ms
79,324 KB
testcase_35 AC 87 ms
78,392 KB
testcase_36 AC 84 ms
77,688 KB
testcase_37 AC 88 ms
77,800 KB
testcase_38 AC 87 ms
78,112 KB
testcase_39 AC 79 ms
76,200 KB
testcase_40 AC 70 ms
71,204 KB
testcase_41 AC 84 ms
77,340 KB
testcase_42 AC 88 ms
80,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n = ni()
s = input()
t = [s[0]]
for i in range(1,n):
    if s[i]!=t[-1]:
        t.append(s[i])
n = len(t)
u = []
z  = 0
for i in range(n):
    u.append(t[i])
    while len(u)>=3 and u[-1]==u[-3]:
        u.pop()
        u.pop()
        z += 1
m = len(u)
print(z+1+m*2//3)
0