結果

問題 No.2723 Fortune-telling by Flowers
ユーザー yansi819
提出日時 2024-05-31 05:34:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 121,436 KB
最終ジャッジ日時 2024-12-20 21:44:05
合計ジャッジ時間 3,855 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    N = int(input())
    S = input().rstrip()
    D = []
    k = S[0]
    cnt = 1
    for i in range(1, len(S)):
        if S[i] == k:
            cnt += 1
        else:
            D.append((k, cnt))
            k = S[i]
            cnt = 1
    D.append((k, cnt))
    K, P = 0, 0
    for k, cnt in D:
        if k == "K":
            K += 1
        elif k == "P":
            P += 1
    print("K" if K >= P else "P")
0