結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-05 19:35:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 455 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 457 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 15,548 KB
最終ジャッジ日時 2023-10-12 06:43:37
合計ジャッジ時間 15,764 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,096 KB
testcase_01 AC 119 ms
14,992 KB
testcase_02 AC 127 ms
15,332 KB
testcase_03 AC 170 ms
15,256 KB
testcase_04 AC 252 ms
15,144 KB
testcase_05 AC 167 ms
15,160 KB
testcase_06 AC 184 ms
15,128 KB
testcase_07 AC 207 ms
15,292 KB
testcase_08 AC 447 ms
15,520 KB
testcase_09 AC 278 ms
15,288 KB
testcase_10 AC 290 ms
15,512 KB
testcase_11 AC 401 ms
15,420 KB
testcase_12 AC 80 ms
15,160 KB
testcase_13 AC 78 ms
15,088 KB
testcase_14 AC 78 ms
15,100 KB
testcase_15 AC 83 ms
15,144 KB
testcase_16 AC 80 ms
15,184 KB
testcase_17 AC 455 ms
15,256 KB
testcase_18 AC 287 ms
15,176 KB
testcase_19 AC 178 ms
15,348 KB
testcase_20 AC 363 ms
15,392 KB
testcase_21 AC 88 ms
15,216 KB
testcase_22 AC 155 ms
15,048 KB
testcase_23 AC 78 ms
15,168 KB
testcase_24 AC 82 ms
15,268 KB
testcase_25 AC 83 ms
15,084 KB
testcase_26 AC 81 ms
15,284 KB
testcase_27 AC 80 ms
15,080 KB
testcase_28 AC 81 ms
15,148 KB
testcase_29 AC 84 ms
15,128 KB
testcase_30 AC 79 ms
15,100 KB
testcase_31 AC 79 ms
15,124 KB
testcase_32 AC 81 ms
15,332 KB
testcase_33 AC 398 ms
15,436 KB
testcase_34 AC 310 ms
15,344 KB
testcase_35 AC 321 ms
15,336 KB
testcase_36 AC 188 ms
15,168 KB
testcase_37 AC 352 ms
15,028 KB
testcase_38 AC 183 ms
15,312 KB
testcase_39 AC 322 ms
15,548 KB
testcase_40 AC 333 ms
15,452 KB
testcase_41 AC 341 ms
15,252 KB
testcase_42 AC 362 ms
15,536 KB
testcase_43 AC 343 ms
15,312 KB
testcase_44 AC 114 ms
15,380 KB
testcase_45 AC 442 ms
15,448 KB
testcase_46 AC 94 ms
15,236 KB
testcase_47 AC 156 ms
15,252 KB
testcase_48 AC 289 ms
15,296 KB
testcase_49 AC 158 ms
14,996 KB
testcase_50 AC 279 ms
15,228 KB
testcase_51 AC 251 ms
15,400 KB
testcase_52 AC 231 ms
15,088 KB
testcase_53 AC 438 ms
15,500 KB
testcase_54 AC 229 ms
15,184 KB
testcase_55 AC 87 ms
15,160 KB
testcase_56 AC 313 ms
15,516 KB
testcase_57 AC 209 ms
15,228 KB
testcase_58 AC 82 ms
15,080 KB
testcase_59 AC 79 ms
14,988 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).tap do |it|
  N.times do |i|
    it[i + 1] = it[i] + (S[i] == 'E' ? 1 : 0)
  end
end
H = Array.new(N + 1, 0).tap do |it|
  N.times do |i|
    it[i + 1] = it[i] + A[i]
  end
end

dp = Array.new(E[N] + 1, max(H[N] * 2, K.max * 2))

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


0