結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー simansiman
提出日時 2021-05-31 11:28:30
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,210 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-26 08:04:09
合計ジャッジ時間 25,732 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
12,288 KB
testcase_01 AC 278 ms
12,416 KB
testcase_02 AC 98 ms
12,416 KB
testcase_03 AC 299 ms
12,160 KB
testcase_04 AC 314 ms
12,288 KB
testcase_05 AC 111 ms
12,160 KB
testcase_06 AC 501 ms
12,416 KB
testcase_07 AC 461 ms
12,288 KB
testcase_08 AC 960 ms
12,672 KB
testcase_09 AC 623 ms
12,416 KB
testcase_10 AC 716 ms
12,416 KB
testcase_11 AC 859 ms
12,288 KB
testcase_12 AC 82 ms
12,032 KB
testcase_13 AC 81 ms
12,160 KB
testcase_14 AC 83 ms
12,160 KB
testcase_15 AC 84 ms
12,160 KB
testcase_16 AC 81 ms
12,160 KB
testcase_17 AC 1,210 ms
12,800 KB
testcase_18 AC 260 ms
12,544 KB
testcase_19 AC 570 ms
12,416 KB
testcase_20 AC 405 ms
12,416 KB
testcase_21 AC 137 ms
12,160 KB
testcase_22 AC 94 ms
12,160 KB
testcase_23 AC 85 ms
12,160 KB
testcase_24 AC 89 ms
12,160 KB
testcase_25 AC 93 ms
12,160 KB
testcase_26 AC 86 ms
12,160 KB
testcase_27 AC 84 ms
12,032 KB
testcase_28 AC 86 ms
12,032 KB
testcase_29 AC 89 ms
12,160 KB
testcase_30 AC 89 ms
12,288 KB
testcase_31 AC 88 ms
12,288 KB
testcase_32 AC 89 ms
12,160 KB
testcase_33 AC 440 ms
12,160 KB
testcase_34 AC 739 ms
12,416 KB
testcase_35 AC 674 ms
12,416 KB
testcase_36 AC 222 ms
12,160 KB
testcase_37 AC 452 ms
12,288 KB
testcase_38 AC 466 ms
12,288 KB
testcase_39 AC 778 ms
12,544 KB
testcase_40 AC 850 ms
12,416 KB
testcase_41 AC 857 ms
12,416 KB
testcase_42 AC 660 ms
12,672 KB
testcase_43 AC 879 ms
12,544 KB
testcase_44 AC 364 ms
12,416 KB
testcase_45 AC 848 ms
12,288 KB
testcase_46 AC 174 ms
12,416 KB
testcase_47 AC 402 ms
12,160 KB
testcase_48 AC 307 ms
12,288 KB
testcase_49 AC 354 ms
12,288 KB
testcase_50 AC 421 ms
12,032 KB
testcase_51 AC 502 ms
12,288 KB
testcase_52 AC 486 ms
12,160 KB
testcase_53 AC 734 ms
12,544 KB
testcase_54 AC 221 ms
12,416 KB
testcase_55 AC 109 ms
12,160 KB
testcase_56 AC 624 ms
12,288 KB
testcase_57 AC 420 ms
12,032 KB
testcase_58 AC 83 ms
12,032 KB
testcase_59 AC 81 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp
A = gets.split.map(&:to_i)
Q = gets.to_i
K = gets.split.map(&:to_i)
E = [0]
R = [0]
e_cnt = 0

S.each_char do |ch|
  e_cnt += 1 if ch == 'E'
  E << e_cnt
end

A.each do |a|
  R << R.last + a
end

K.each do |k|
  l = 0
  r = 0
  ans = 0

  while l <= r
    power = R[r] - R[l]
    cnt = E[r] - E[l]

    if power <= k
      ans = cnt if ans < cnt
    end

    if l == r && r + 1 <= N
      r += 1
    elsif power < k && r + 1 <= N
      r += 1
    else
      l += 1
    end
  end

  puts ans
end
0