結果

問題 No.1471 Sort Queries
ユーザー DrDrpilot
提出日時 2022-06-08 13:51:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 79,104 KB
最終ジャッジ日時 2024-09-21 05:05:25
合計ジャッジ時間 4,561 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

alp='abcdefghijklmnopqrstuvwxyz'
n,q=map(int,input().split())
s=input()
cnt=[[0]*(n+1) for _ in range(26)]
for i in range(26):
    ch=alp[i]
    for j in range(n):
        if s[j]==ch:
            cnt[i][j+1]+=1
for i in range(26):
    for j in range(n):
        cnt[i][j+1]+=cnt[i][j]
for _ in range(q):
    l,r,x=map(int,input().split())
    tmp=0
    for i in range(26):
        tmp+=cnt[i][r]-cnt[i][l-1]
        if tmp>=x:
            print(alp[i])
            break
0