結果

問題 No.1471 Sort Queries
ユーザー FromBooskaFromBooska
提出日時 2023-03-17 20:21:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 79,488 KB
最終ジャッジ日時 2024-09-18 10:08:22
合計ジャッジ時間 5,624 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 38 ms
51,968 KB
testcase_03 AC 48 ms
60,928 KB
testcase_04 AC 45 ms
59,264 KB
testcase_05 AC 45 ms
59,008 KB
testcase_06 AC 40 ms
51,968 KB
testcase_07 AC 57 ms
63,616 KB
testcase_08 AC 54 ms
60,928 KB
testcase_09 AC 47 ms
59,648 KB
testcase_10 AC 39 ms
51,712 KB
testcase_11 AC 45 ms
58,880 KB
testcase_12 AC 54 ms
61,312 KB
testcase_13 AC 79 ms
72,704 KB
testcase_14 AC 77 ms
71,680 KB
testcase_15 AC 89 ms
77,312 KB
testcase_16 AC 75 ms
71,296 KB
testcase_17 AC 74 ms
71,424 KB
testcase_18 AC 73 ms
70,528 KB
testcase_19 AC 78 ms
72,064 KB
testcase_20 AC 89 ms
77,056 KB
testcase_21 AC 75 ms
71,808 KB
testcase_22 AC 89 ms
77,568 KB
testcase_23 AC 110 ms
78,848 KB
testcase_24 AC 105 ms
78,336 KB
testcase_25 AC 112 ms
78,944 KB
testcase_26 AC 108 ms
78,132 KB
testcase_27 AC 111 ms
79,232 KB
testcase_28 AC 112 ms
78,976 KB
testcase_29 AC 104 ms
77,952 KB
testcase_30 AC 95 ms
78,336 KB
testcase_31 AC 115 ms
78,464 KB
testcase_32 AC 115 ms
78,080 KB
testcase_33 AC 116 ms
79,232 KB
testcase_34 AC 126 ms
79,488 KB
testcase_35 AC 122 ms
79,360 KB
testcase_36 AC 116 ms
79,360 KB
testcase_37 AC 117 ms
79,360 KB
testcase_38 AC 102 ms
79,488 KB
testcase_39 AC 105 ms
79,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# alphabet count tableを用意するか
alphabets = 'abcdefghijklmnopqrstuvwxyz'
dic = {}
for i in range(26):
    dic[alphabets[i]] = i

N, Q = map(int, input().split())
S = input()
dp = [[0]*26 for i in range(N+1)]
for i in range(1, N+1):
    letter_num = dic[S[i-1]]
    for j in range(26):
        dp[i][j] = dp[i-1][j]
    dp[i][letter_num] += 1
    #print(dp[i])

for q in range(Q):
    l, r, x = map(int, input().split())
    count = [0]*26
    for i in range(26):
        count[i] = dp[r][i]-dp[l-1][i]
    x_remainder = x
    for i in range(26):
        if count[i] < x_remainder:
            x_remainder -= count[i]
        elif count[i] >= x_remainder:
            #print(count)
            print(alphabets[i])
            break

0