結果
問題 | No.2716 Falcon Method |
ユーザー |
![]() |
提出日時 | 2024-04-05 22:34:58 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 772 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 81,876 KB |
実行使用メモリ | 114,236 KB |
最終ジャッジ日時 | 2024-10-01 02:44:56 |
合計ジャッジ時間 | 9,112 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 RE * 10 |
ソースコード
from itertools import accumulatefrom bisect import bisect_left, bisect_rightN, Q = map(int, input().split())S = [*input()]D = [int(ch == "D") for ch in S]R = [int(ch == "R") for ch in S]Dwa = [0] + [*accumulate(D)]Rwa = [0] + [*accumulate(R)]DELTA = sum(D)RHO = sum(R)def estimate_time(X, P, PI, wa):t = 0q, r = divmod(X, PI)t += q*NX = rtail = wa[N] - wa[P]if tail < X:X -= tailt += N-Pi = 0else:i = Pj = bisect_left(wa, wa[i] + X)t += j-ireturn tdef solve(H, W, P):t_D = estimate_time(H, P, DELTA, Dwa)t_R = estimate_time(W, P, RHO, Rwa)t = min(t_D, t_R)return (P+t)%Nfor _ in range(Q):H, W, P = map(int, input().split())ans = solve(H, W, P)print(ans)