結果
問題 | No.2723 Fortune-telling by Flowers |
ユーザー | なえしら |
提出日時 | 2024-04-12 21:56:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 382 ms / 2,000 ms |
コード長 | 357 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 136,188 KB |
最終ジャッジ日時 | 2024-10-02 23:16:23 |
合計ジャッジ時間 | 3,200 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
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')