結果

問題 No.1471 Sort Queries
ユーザー sasa8uyauya
提出日時 2025-07-22 02:08:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 82,780 KB
実行使用メモリ 79,196 KB
最終ジャッジ日時 2025-07-22 02:08:58
合計ジャッジ時間 5,441 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

n,Q=map(int,input().split())
s=input()
K=26
c=[[0]*(n+1) for i in range(K)]
for i in range(n):
  c[ord(s[i])-ord("a")][i]+=1
  for j in range(K):
    c[j][i]+=c[j][i-1]
for _ in range(Q):
  l,r,x=map(int,input().split())
  l-=1
  r-=1
  g=0
  for i in range(K):
    d=c[i][r]-c[i][l-1]
    if x<=g+d:
      print(chr(i+ord("a")))
      break
    g+=d
0