結果

問題 No.2723 Fortune-telling by Flowers
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-12 22:14:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 467 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 94,996 KB
最終ジャッジ日時 2024-04-12 22:14:27
合計ジャッジ時間 3,231 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,952 KB
testcase_01 AC 125 ms
77,344 KB
testcase_02 AC 166 ms
77,488 KB
testcase_03 AC 365 ms
77,708 KB
testcase_04 AC 467 ms
77,540 KB
testcase_05 AC 85 ms
94,996 KB
testcase_06 AC 40 ms
56,884 KB
testcase_07 AC 71 ms
82,672 KB
testcase_08 AC 71 ms
82,896 KB
testcase_09 AC 171 ms
77,384 KB
testcase_10 AC 111 ms
76,656 KB
testcase_11 AC 73 ms
75,460 KB
testcase_12 AC 73 ms
77,456 KB
testcase_13 AC 77 ms
82,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split("-")
	pp, pk, kk = 0, 0, 0
	for i in a:
		if len(i) == 0:
			continue
		if i[0] == 'P' and i[-1] == 'P':
			pp += 1
		elif i[0] == 'K' and i[-1] == 'K':
			kk += 1
		else:
			pk += 1
	kk += (pk + 1) // 2
	pp += pk // 2
	if pk % 2 == 0:
		if kk >= pp:
			print("K")
		else:
			print("P")
	else:
		if kk > pp:
			print("K")
		else:
			print("P")
0