結果

問題 No.1471 Sort Queries
ユーザー wolgnik
提出日時 2021-04-09 21:34:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 78,800 KB
最終ジャッジ日時 2024-06-25 04:25:45
合計ジャッジ時間 3,882 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
S = list(map(lambda c: ord(c) - ord("a"), list(input())[: -1]))

cs = [[0] * (N + 1) for _ in range(26)]
for i in range(26):
  for j in range(N): cs[i][j + 1] = cs[i][j] + (S[j] == i)

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