結果

問題 No.2716 Falcon Method
ユーザー 👑 p-adicp-adic
提出日時 2024-02-07 17:39:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 410 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 40,604 KB
最終ジャッジ日時 2024-02-07 17:39:59
合計ジャッジ時間 12,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,112 KB
testcase_01 AC 26 ms
10,112 KB
testcase_02 AC 26 ms
10,112 KB
testcase_03 AC 26 ms
10,112 KB
testcase_04 AC 26 ms
10,112 KB
testcase_05 AC 27 ms
10,112 KB
testcase_06 AC 42 ms
10,240 KB
testcase_07 AC 46 ms
10,240 KB
testcase_08 AC 46 ms
10,240 KB
testcase_09 AC 48 ms
10,240 KB
testcase_10 AC 40 ms
10,240 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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