結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー | naesira |
提出日時 | 2024-04-12 21:56:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 383 ms / 2,000 ms |
コード長 | 357 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 82,264 KB |
実行使用メモリ | 136,324 KB |
最終ジャッジ日時 | 2024-04-12 21:56:07 |
合計ジャッジ時間 | 3,341 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,544 KB |
testcase_01 | AC | 97 ms
76,700 KB |
testcase_02 | AC | 139 ms
76,532 KB |
testcase_03 | AC | 358 ms
77,460 KB |
testcase_04 | AC | 383 ms
77,644 KB |
testcase_05 | AC | 58 ms
75,864 KB |
testcase_06 | AC | 134 ms
108,588 KB |
testcase_07 | AC | 176 ms
136,324 KB |
testcase_08 | AC | 178 ms
135,876 KB |
testcase_09 | AC | 137 ms
76,520 KB |
testcase_10 | AC | 120 ms
77,420 KB |
testcase_11 | AC | 96 ms
80,620 KB |
testcase_12 | AC | 146 ms
114,780 KB |
testcase_13 | AC | 173 ms
134,828 KB |
ソースコード
def run_length_encoding(A): B = [] for a in A: if B and B[-1][0] == a: B[-1][1] += 1 else: B.append([a, 1]) return B for _ in range(T := int(input())): N = int(input()) S = input() T = run_length_encoding(S) K = P = 0 for c, l in T: if c == 'K': K += 1 elif c == 'P': P += 1 print('K' if K >= P else 'P')