結果

問題 No.1471 Sort Queries
ユーザー simansiman
提出日時 2021-04-13 04:45:59
言語 Ruby
(3.3.0)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 11,228 KB
実行使用メモリ 18,760 KB
最終ジャッジ日時 2023-09-11 08:39:12
合計ジャッジ時間 7,837 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,156 KB
testcase_01 AC 82 ms
15,140 KB
testcase_02 AC 81 ms
15,296 KB
testcase_03 AC 80 ms
15,140 KB
testcase_04 AC 80 ms
15,312 KB
testcase_05 AC 83 ms
15,140 KB
testcase_06 AC 79 ms
15,088 KB
testcase_07 AC 80 ms
15,256 KB
testcase_08 AC 81 ms
15,320 KB
testcase_09 AC 80 ms
15,244 KB
testcase_10 AC 80 ms
15,172 KB
testcase_11 AC 79 ms
15,284 KB
testcase_12 AC 80 ms
15,276 KB
testcase_13 AC 117 ms
16,580 KB
testcase_14 AC 116 ms
16,412 KB
testcase_15 AC 130 ms
16,712 KB
testcase_16 AC 109 ms
15,624 KB
testcase_17 AC 110 ms
16,824 KB
testcase_18 AC 104 ms
16,416 KB
testcase_19 AC 108 ms
15,768 KB
testcase_20 AC 131 ms
16,608 KB
testcase_21 AC 113 ms
16,464 KB
testcase_22 AC 111 ms
16,680 KB
testcase_23 AC 157 ms
17,920 KB
testcase_24 AC 156 ms
18,056 KB
testcase_25 AC 182 ms
17,968 KB
testcase_26 AC 155 ms
17,004 KB
testcase_27 AC 173 ms
18,460 KB
testcase_28 AC 174 ms
18,420 KB
testcase_29 AC 153 ms
17,180 KB
testcase_30 AC 156 ms
17,876 KB
testcase_31 AC 184 ms
17,480 KB
testcase_32 AC 179 ms
16,856 KB
testcase_33 AC 203 ms
18,536 KB
testcase_34 AC 210 ms
18,520 KB
testcase_35 AC 207 ms
18,568 KB
testcase_36 AC 201 ms
18,540 KB
testcase_37 AC 201 ms
18,692 KB
testcase_38 AC 201 ms
18,760 KB
testcase_39 AC 204 ms
18,564 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, Q = gets.split.map(&:to_i)
S = gets.chomp
counter = Array.new(N + 1) { Array.new(26, 0) }

N.times do |i|
  v = S[i].ord - 'a'.ord

  26.times do |j|
    counter[i + 1][j] = counter[i][j]
  end

  counter[i + 1][v] += 1
end

v = Array.new(26, 0)

Q.times do
  l, r, x = gets.split.map(&:to_i)

  26.times do |i|
    v[i] = counter[r][i] - counter[l - 1][i]
  end

  1.upto(25) do |i|
    v[i] += v[i - 1]
  end

  idx = v.bsearch_index { |c| c >= x }
  puts (idx + 97).chr
end
0