結果

問題 No.1471 Sort Queries
ユーザー FromBooskaFromBooska
提出日時 2023-03-17 20:21:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 78,896 KB
最終ジャッジ日時 2023-10-18 13:50:13
合計ジャッジ時間 5,996 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,276 KB
testcase_01 AC 38 ms
53,276 KB
testcase_02 AC 38 ms
53,276 KB
testcase_03 AC 47 ms
62,044 KB
testcase_04 AC 46 ms
59,628 KB
testcase_05 AC 44 ms
59,600 KB
testcase_06 AC 38 ms
53,276 KB
testcase_07 AC 53 ms
64,504 KB
testcase_08 AC 49 ms
62,072 KB
testcase_09 AC 46 ms
59,860 KB
testcase_10 AC 38 ms
53,276 KB
testcase_11 AC 45 ms
59,600 KB
testcase_12 AC 50 ms
62,072 KB
testcase_13 AC 77 ms
72,812 KB
testcase_14 AC 73 ms
72,812 KB
testcase_15 AC 90 ms
77,020 KB
testcase_16 AC 74 ms
72,812 KB
testcase_17 AC 72 ms
72,812 KB
testcase_18 AC 71 ms
70,764 KB
testcase_19 AC 75 ms
72,812 KB
testcase_20 AC 88 ms
77,044 KB
testcase_21 AC 76 ms
72,812 KB
testcase_22 AC 93 ms
77,148 KB
testcase_23 AC 105 ms
78,260 KB
testcase_24 AC 103 ms
78,264 KB
testcase_25 AC 113 ms
78,380 KB
testcase_26 AC 106 ms
77,632 KB
testcase_27 AC 108 ms
78,844 KB
testcase_28 AC 109 ms
78,800 KB
testcase_29 AC 104 ms
77,704 KB
testcase_30 AC 95 ms
78,000 KB
testcase_31 AC 112 ms
78,064 KB
testcase_32 AC 113 ms
77,572 KB
testcase_33 AC 117 ms
78,896 KB
testcase_34 AC 121 ms
78,892 KB
testcase_35 AC 119 ms
78,892 KB
testcase_36 AC 115 ms
78,892 KB
testcase_37 AC 114 ms
78,896 KB
testcase_38 AC 98 ms
78,688 KB
testcase_39 AC 103 ms
78,684 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