結果

問題 No.2716 Falcon Method
ユーザー 👑 timitimi
提出日時 2024-04-05 22:43:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 554 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 103,548 KB
最終ジャッジ日時 2024-04-05 22:43:21
合計ジャッジ時間 10,335 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,460 KB
testcase_01 AC 41 ms
53,460 KB
testcase_02 AC 43 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 70 ms
68,376 KB
testcase_07 AC 73 ms
70,452 KB
testcase_08 AC 71 ms
70,452 KB
testcase_09 AC 72 ms
70,452 KB
testcase_10 AC 69 ms
68,376 KB
testcase_11 AC 428 ms
103,240 KB
testcase_12 AC 416 ms
102,612 KB
testcase_13 AC 360 ms
102,740 KB
testcase_14 AC 490 ms
96,808 KB
testcase_15 AC 371 ms
99,768 KB
testcase_16 AC 433 ms
96,828 KB
testcase_17 AC 488 ms
97,056 KB
testcase_18 AC 528 ms
99,760 KB
testcase_19 AC 420 ms
96,804 KB
testcase_20 AC 409 ms
99,780 KB
testcase_21 AC 345 ms
97,320 KB
testcase_22 AC 468 ms
103,548 KB
testcase_23 AC 538 ms
99,680 KB
testcase_24 AC 511 ms
103,544 KB
testcase_25 AC 39 ms
53,460 KB
testcase_26 AC 39 ms
53,460 KB
testcase_27 AC 554 ms
102,760 KB
testcase_28 AC 520 ms
102,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0