結果
問題 |
No.2716 Falcon Method
|
ユーザー |
![]() |
提出日時 | 2024-04-05 22:43:11 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 557 ms / 2,000 ms |
コード長 | 523 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 82,444 KB |
実行使用メモリ | 103,932 KB |
最終ジャッジ日時 | 2024-10-01 02:49:41 |
合計ジャッジ時間 | 10,087 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
N,Q=map(int, input().split()) S=input() R,D=[0],[0] for s in S: R.append(R[-1]);D.append(D[-1]) if s=='R': R[-1]+=1 else: D[-1]+=1 import bisect for i in range(Q): h,w,p=map(int, input().split()) h+=D[p];w+=R[p] sh=D[-1] if sh!=0: ss=max(0,(h-1)//sh) sn=h-ss*sh p=bisect.bisect_left(D,sn) dd=ss*N+p else: dd=10**10 sh=R[-1] if sh!=0: ss=max(0,(w-1)//sh) sn=w-ss*sh p=bisect.bisect_left(R,sn) rr=ss*N+p else: rr=10**10 ans=min(dd,rr)%N print(ans)