結果

問題 No.2716 Falcon Method
ユーザー rlangevinrlangevin
提出日時 2024-04-07 01:30:27
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,026 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 103,836 KB
最終ジャッジ日時 2024-04-07 01:30:33
合計ジャッジ時間 5,807 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 RE -
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 34 ms
53,460 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 55 ms
68,312 KB
testcase_08 AC 57 ms
68,316 KB
testcase_09 AC 57 ms
68,316 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 206 ms
102,356 KB
testcase_13 AC 177 ms
102,704 KB
testcase_14 AC 209 ms
98,108 KB
testcase_15 AC 186 ms
101,392 KB
testcase_16 AC 205 ms
98,192 KB
testcase_17 AC 252 ms
99,252 KB
testcase_18 AC 226 ms
100,344 KB
testcase_19 AC 183 ms
97,676 KB
testcase_20 AC 172 ms
101,084 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 234 ms
103,836 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 220 ms
103,700 KB
testcase_28 AC 214 ms
103,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = list(input())
h = S.count("D")
w = N - h
T1 = [0] * 3 * N
T2 = [0] * 3 * N
Ac1 = [0] * (3 * N + 1)
Ac2 = [0] * (3 * N + 1)
for i in range(N):
    if S[i] == "D":
        T1[i] += 1
        T1[i + N] += 1
        T1[i + 2 * N] += 1
    else:
        T2[i] += 1
        T2[i + N] += 1
        T2[i + 2 * N] += 1
        
for i in range(3 * N):
    Ac1[i + 1] = Ac1[i] + T1[i]
    Ac2[i + 1] = Ac2[i] + T2[i]
        
def BinarySearch(check, yes = 10 ** 18, no = -1):
    while abs(yes - no) != 1:
        mid = (yes + no)//2
        if check(mid):
            yes = mid
        else:
            no = mid
    return yes

def check1(m):
    return (H - h * m) > 0 and (W - w * m) > 0

def check2(r):
    x = Ac1[r] - Ac1[P]
    y = Ac2[r] - Ac2[P]
    return H - x <= 0 or W - y <= 0

for _ in range(Q):
    H, W, P = map(int, input().split())
    m = min((H - 1)//h, (W - 1)//w)
    H -= m * h
    W -= m * w
    print(BinarySearch(check2, 3 * N, P)%N)
0