結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
dp_ijk
|
| 提出日時 | 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 accumulate
from bisect import bisect_left, bisect_right
N, 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 = 0
q, r = divmod(X, PI)
t += q*N
X = r
tail = wa[N] - wa[P]
if tail < X:
X -= tail
t += N-P
i = 0
else:
i = P
j = bisect_left(wa, wa[i] + X)
t += j-i
return t
def 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)%N
for _ in range(Q):
H, W, P = map(int, input().split())
ans = solve(H, W, P)
print(ans)
dp_ijk