結果

問題 No.2716 Falcon Method
ユーザー 👑 p-adicp-adic
提出日時 2024-02-07 17:40:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 592 ms / 2,000 ms
コード長 410 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 83,356 KB
最終ジャッジ日時 2024-02-07 17:40:44
合計ジャッジ時間 10,063 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 92 ms
75,048 KB
testcase_07 AC 72 ms
73,708 KB
testcase_08 AC 79 ms
74,300 KB
testcase_09 AC 72 ms
73,700 KB
testcase_10 AC 77 ms
74,344 KB
testcase_11 AC 432 ms
82,508 KB
testcase_12 AC 437 ms
82,476 KB
testcase_13 AC 327 ms
82,756 KB
testcase_14 AC 489 ms
81,496 KB
testcase_15 AC 383 ms
82,412 KB
testcase_16 AC 449 ms
81,512 KB
testcase_17 AC 506 ms
81,736 KB
testcase_18 AC 592 ms
82,012 KB
testcase_19 AC 407 ms
81,408 KB
testcase_20 AC 381 ms
82,152 KB
testcase_21 AC 362 ms
81,660 KB
testcase_22 AC 430 ms
82,976 KB
testcase_23 AC 562 ms
83,356 KB
testcase_24 AC 469 ms
82,848 KB
testcase_25 AC 36 ms
53,460 KB
testcase_26 AC 35 ms
53,460 KB
testcase_27 AC 469 ms
82,836 KB
testcase_28 AC 488 ms
83,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R=input,range
J=lambda:map(int,I().split())
N,Q=J()
S=I()
c=[0]*2
for s in S:c[s>'D']+=1
t=[[0]*(N*2+1)for b in R(2)]
for b in R(2):
	for i in R(N*2):t[b][i+1]=t[b][i]+(S[i%N]=="DR"[b])
for q in R(Q):
	H=list(J())
	P=H[2]
	d=[9**16]*2
	for b in R(2):
		if c[b]:
			q=(H[b]-1)//c[b]
			l,r=P,P+N
			while l+1<r:
				m=(l+r)//2
				if t[b][m]<H[b]+t[b][P]-q*c[b]:l=m
				else:r=m
			d[b]=q*N+r
	print(min(d)%N)
0