結果

問題 No.2723 Fortune-telling by Flowers
ユーザー pitPpitP
提出日時 2024-04-12 21:46:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 152,080 KB
最終ジャッジ日時 2024-04-12 21:46:34
合計ジャッジ時間 3,940 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,488 KB
testcase_01 AC 104 ms
76,856 KB
testcase_02 AC 154 ms
76,696 KB
testcase_03 AC 358 ms
77,564 KB
testcase_04 AC 447 ms
78,132 KB
testcase_05 AC 80 ms
97,180 KB
testcase_06 AC 153 ms
128,512 KB
testcase_07 AC 190 ms
152,080 KB
testcase_08 AC 188 ms
151,868 KB
testcase_09 AC 150 ms
76,936 KB
testcase_10 AC 145 ms
76,732 KB
testcase_11 AC 158 ms
79,520 KB
testcase_12 AC 148 ms
114,088 KB
testcase_13 AC 201 ms
149,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    N = int(input())
    S = list(input())

    now = S[0]
    cnt = 1
    dat = []
    for i in range(1, N):
        if S[i] != now:
            dat.append([now, cnt])
            cnt = 1
            now = S[i]
        else:
            cnt += 1
    dat.append([now, cnt])
    # print(dat)

    cntp, cntk = 0, 0
    for c, _ in dat:
        if c == 'P':
            cntp += 1
        if c == 'K':
            cntk += 1
    
    print("K" if cntp <= cntk else "P")
0