結果

問題 No.1471 Sort Queries
ユーザー DrDrpilot
提出日時 2022-06-08 13:51:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 471 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-09-21 05:05:20
合計ジャッジ時間 6,873 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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