結果

問題 No.2716 Falcon Method
ユーザー ecotteaecottea
提出日時 2024-02-03 19:00:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 79,852 KB
最終ジャッジ日時 2024-02-03 19:01:02
合計ジャッジ時間 11,145 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 67 ms
68,824 KB
testcase_07 AC 67 ms
68,812 KB
testcase_08 AC 68 ms
68,812 KB
testcase_09 AC 85 ms
68,816 KB
testcase_10 AC 64 ms
68,840 KB
testcase_11 AC 463 ms
79,272 KB
testcase_12 AC 351 ms
79,292 KB
testcase_13 AC 326 ms
79,348 KB
testcase_14 AC 408 ms
78,752 KB
testcase_15 AC 315 ms
79,176 KB
testcase_16 AC 391 ms
78,772 KB
testcase_17 AC 409 ms
78,896 KB
testcase_18 AC 473 ms
79,032 KB
testcase_19 AC 386 ms
78,708 KB
testcase_20 AC 308 ms
79,132 KB
testcase_21 AC 401 ms
78,812 KB
testcase_22 AC 530 ms
79,452 KB
testcase_23 AC 467 ms
79,452 KB
testcase_24 AC 486 ms
79,440 KB
testcase_25 AC 36 ms
53,460 KB
testcase_26 AC 36 ms
53,460 KB
testcase_27 AC 442 ms
79,852 KB
testcase_28 AC 469 ms
79,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, q = map(int, input().split())
s = input()

d = [0] * (n + 1)
r = [0] * (n + 1)
for i in range(n):
    d[i + 1] = d[i] + (1 if s[i] == 'D' else 0)
    r[i + 1] = r[i] + (1 if s[i] == 'R' else 0)

for _ in range(q):
    h, w, p = map(int, input().split())

    ok = h + w
    ng = 0
    while ok - ng > 1:
        mid = (ok + ng) // 2

        d_cnt = 0
        d_cnt += d[n] * ((p + mid) // n) + d[(p + mid) % n]
        d_cnt -= d[n] * (p // n) + d[p % n]

        r_cnt = 0
        r_cnt += r[n] * ((p + mid) // n) + r[(p + mid) % n]
        r_cnt -= r[n] * (p // n) + r[p % n]

        if d_cnt >= h or r_cnt >= w:
            ok = mid
        else:
            ng = mid
    
    print((p + ok) % n)
0