結果

問題 No.1471 Sort Queries
コンテスト
ユーザー 330Xs
提出日時 2022-02-03 16:53:50
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 538 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 228 ms
コンパイル使用メモリ 85,576 KB
実行使用メモリ 85,036 KB
最終ジャッジ日時 2026-03-04 11:48:52
合計ジャッジ時間 3,819 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
n,m = map(int,input().split())
s = list(map(str,input()))
ss = sorted(s)
d = defaultdict(list)
for i in range(26):
    d[chr(97+i)].append(0)
    for j in range(n):
        if(s[j] == chr(97+i)):
            d[chr(97+i)].append(d[chr(97+i)][-1] + 1)
        else:
            d[chr(97+i)].append(d[chr(97+i)][-1])

for _ in range(m):
    a,b,c = map(int,input().split())
    cnt = 0
    for key in d:
        cnt += d[key][b] - d[key][a-1]
        if(cnt >= c):
            print(key)
            break
0