結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-06 11:27:18
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 530 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 11,348 KB
実行使用メモリ 15,620 KB
最終ジャッジ日時 2023-08-24 19:48:39
合計ジャッジ時間 14,756 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,340 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 160 ms
15,104 KB
testcase_04 AC 233 ms
15,256 KB
testcase_05 AC 155 ms
15,204 KB
testcase_06 AC 167 ms
15,364 KB
testcase_07 AC 188 ms
15,292 KB
testcase_08 RE -
testcase_09 AC 259 ms
15,512 KB
testcase_10 AC 269 ms
15,496 KB
testcase_11 AC 362 ms
15,560 KB
testcase_12 AC 78 ms
15,332 KB
testcase_13 AC 78 ms
15,040 KB
testcase_14 AC 78 ms
15,136 KB
testcase_15 AC 78 ms
15,072 KB
testcase_16 AC 77 ms
15,328 KB
testcase_17 AC 414 ms
15,420 KB
testcase_18 AC 263 ms
15,160 KB
testcase_19 AC 163 ms
15,328 KB
testcase_20 AC 331 ms
15,516 KB
testcase_21 AC 87 ms
15,300 KB
testcase_22 AC 144 ms
15,104 KB
testcase_23 AC 77 ms
15,100 KB
testcase_24 AC 82 ms
15,256 KB
testcase_25 AC 81 ms
15,072 KB
testcase_26 AC 82 ms
15,312 KB
testcase_27 AC 80 ms
15,140 KB
testcase_28 AC 81 ms
15,032 KB
testcase_29 AC 83 ms
15,268 KB
testcase_30 AC 80 ms
15,148 KB
testcase_31 RE -
testcase_32 AC 83 ms
15,136 KB
testcase_33 AC 365 ms
15,596 KB
testcase_34 AC 282 ms
15,384 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 321 ms
15,460 KB
testcase_38 AC 168 ms
15,368 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 311 ms
15,416 KB
testcase_42 AC 327 ms
15,360 KB
testcase_43 AC 311 ms
15,540 KB
testcase_44 AC 108 ms
15,168 KB
testcase_45 AC 396 ms
15,292 KB
testcase_46 AC 90 ms
15,096 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 260 ms
15,064 KB
testcase_51 AC 227 ms
15,340 KB
testcase_52 AC 217 ms
15,268 KB
testcase_53 RE -
testcase_54 AC 219 ms
15,036 KB
testcase_55 AC 87 ms
15,172 KB
testcase_56 AC 287 ms
15,540 KB
testcase_57 RE -
testcase_58 AC 77 ms
15,036 KB
testcase_59 AC 78 ms
15,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

N = gets.to_i
S = gets.chomp
A = gets.split.map(&:to_i)
Q = gets.to_i
K = gets.split.map(&:to_i)

E = Array.new(N + 1, 0)
H = Array.new(N + 1, 0)

N.times do |i|
  E[i + 1] = E[i] + (S[i] == 'E' ? 1 : 0)
  H[i + 1] = H[i] + A[i]
end

dp = Array.new(E[N] + 10, Float::INFINITY)
dp[0] = 0

(1 .. N).each do |i|
  (0 ... i).each do |j|
    e = E[i] - E[j]
    k = H[i] - H[j]
    dp[e] = min(dp[e], k)
  end
end
puts K.map{|k| (0 .. N).bsearch{|n| dp[n + 1] > k } }
0