結果

問題 No.1471 Sort Queries
ユーザー lie_of_lillie
提出日時 2021-06-14 00:46:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-12-23 16:13:33
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int,input().split())
S=input()

cs = [None for i in range(len(S)+1)]
cs[0] = [0]*26
chidx = [0]*26

for i,s in enumerate(S, 1):
    chidx[ord(s) - ord('a')] += 1 # 文字の累積和
    cs[i] = chidx[:] # コピーする

que = []
for q in range(Q):
    l,r,x=map(int,input().split())
    diff = [ri-li for ri,li in zip(cs[r], cs[l-1])]
    tmp = 0
    for i, d in enumerate(diff, ord('a')):
        tmp += d
        if tmp >= x:
            que.append(chr(i))
            break
print(*que,sep='\n')
0