結果

問題 No.1471 Sort Queries
ユーザー titia
提出日時 2021-04-09 23:54:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-06-25 12:38:09
合計ジャッジ時間 6,423 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

X=[[0]*26 for i in range(len(S)+1)]
for i in range(len(S)):
    x=ord(S[i])-97
    for j in range(26):
        X[i][j]=X[i-1][j]
        
    X[i][x]+=1

#print(X)

for q in range(Q):
    l,r,x=map(int,input().split())
    l-=1
    r-=1
    Y=[0]*26
    for j in range(26):
        Y[j]+=X[r][j]
        Y[j]-=X[l-1][j]

    now=0
    for j in range(26):
        now+=Y[j]
        if now>=x:
            print(chr(97+j))
            break
    
0