結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-06 11:28:56
言語 Ruby
(3.3.0)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 15,544 KB
最終ジャッジ日時 2023-10-12 06:43:52
合計ジャッジ時間 14,290 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,216 KB
testcase_01 AC 112 ms
15,276 KB
testcase_02 AC 119 ms
15,044 KB
testcase_03 AC 160 ms
15,004 KB
testcase_04 AC 232 ms
15,288 KB
testcase_05 AC 156 ms
15,112 KB
testcase_06 AC 168 ms
15,504 KB
testcase_07 AC 189 ms
15,236 KB
testcase_08 AC 404 ms
15,436 KB
testcase_09 AC 262 ms
15,356 KB
testcase_10 AC 275 ms
15,392 KB
testcase_11 AC 366 ms
15,464 KB
testcase_12 AC 79 ms
15,084 KB
testcase_13 AC 79 ms
15,216 KB
testcase_14 AC 86 ms
15,092 KB
testcase_15 AC 79 ms
15,140 KB
testcase_16 AC 78 ms
15,100 KB
testcase_17 AC 413 ms
15,372 KB
testcase_18 AC 261 ms
15,248 KB
testcase_19 AC 166 ms
15,448 KB
testcase_20 AC 334 ms
15,488 KB
testcase_21 AC 87 ms
15,136 KB
testcase_22 AC 144 ms
15,280 KB
testcase_23 AC 82 ms
15,240 KB
testcase_24 AC 82 ms
15,128 KB
testcase_25 AC 83 ms
15,216 KB
testcase_26 AC 81 ms
15,068 KB
testcase_27 AC 79 ms
15,216 KB
testcase_28 AC 81 ms
15,140 KB
testcase_29 AC 81 ms
15,256 KB
testcase_30 AC 80 ms
15,124 KB
testcase_31 AC 80 ms
15,088 KB
testcase_32 AC 84 ms
15,188 KB
testcase_33 AC 364 ms
15,544 KB
testcase_34 AC 280 ms
15,348 KB
testcase_35 AC 296 ms
15,436 KB
testcase_36 AC 181 ms
15,088 KB
testcase_37 AC 319 ms
15,400 KB
testcase_38 AC 168 ms
15,340 KB
testcase_39 AC 296 ms
15,384 KB
testcase_40 AC 306 ms
15,380 KB
testcase_41 AC 313 ms
15,360 KB
testcase_42 AC 328 ms
15,388 KB
testcase_43 AC 313 ms
15,380 KB
testcase_44 AC 107 ms
15,328 KB
testcase_45 AC 398 ms
15,436 KB
testcase_46 AC 93 ms
15,252 KB
testcase_47 AC 144 ms
15,052 KB
testcase_48 AC 270 ms
15,128 KB
testcase_49 AC 152 ms
15,172 KB
testcase_50 AC 262 ms
15,056 KB
testcase_51 AC 226 ms
15,436 KB
testcase_52 AC 217 ms
15,364 KB
testcase_53 AC 412 ms
15,400 KB
testcase_54 AC 223 ms
15,316 KB
testcase_55 AC 87 ms
15,160 KB
testcase_56 AC 289 ms
15,424 KB
testcase_57 AC 195 ms
15,344 KB
testcase_58 AC 79 ms
15,120 KB
testcase_59 AC 80 ms
15,252 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 .. E[N]).bsearch{|n| dp[n + 1] > k } }
0