結果

問題 No.935 う し た ぷ に き あ く ん 笑 ビ - ム
ユーザー 小野寺健小野寺健
提出日時 2021-11-09 11:56:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 872 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 15,600 KB
最終ジャッジ日時 2023-08-11 15:29:18
合計ジャッジ時間 26,109 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
15,144 KB
testcase_01 AC 259 ms
15,092 KB
testcase_02 AC 97 ms
15,292 KB
testcase_03 AC 282 ms
15,156 KB
testcase_04 AC 314 ms
15,100 KB
testcase_05 AC 109 ms
15,092 KB
testcase_06 AC 455 ms
15,164 KB
testcase_07 AC 422 ms
15,272 KB
testcase_08 AC 872 ms
15,432 KB
testcase_09 AC 576 ms
15,376 KB
testcase_10 AC 667 ms
15,544 KB
testcase_11 AC 813 ms
15,344 KB
testcase_12 AC 85 ms
15,300 KB
testcase_13 AC 83 ms
15,140 KB
testcase_14 AC 84 ms
15,268 KB
testcase_15 AC 84 ms
15,288 KB
testcase_16 AC 83 ms
15,168 KB
testcase_17 AC 379 ms
15,428 KB
testcase_18 AC 240 ms
15,192 KB
testcase_19 AC 537 ms
15,556 KB
testcase_20 AC 385 ms
15,176 KB
testcase_21 AC 135 ms
15,136 KB
testcase_22 AC 95 ms
15,304 KB
testcase_23 AC 85 ms
15,192 KB
testcase_24 AC 88 ms
15,248 KB
testcase_25 AC 89 ms
15,148 KB
testcase_26 AC 87 ms
15,164 KB
testcase_27 AC 86 ms
15,408 KB
testcase_28 AC 89 ms
15,136 KB
testcase_29 AC 95 ms
15,252 KB
testcase_30 AC 89 ms
15,152 KB
testcase_31 AC 89 ms
15,164 KB
testcase_32 AC 91 ms
15,292 KB
testcase_33 AC 425 ms
15,200 KB
testcase_34 AC 712 ms
15,556 KB
testcase_35 AC 636 ms
15,320 KB
testcase_36 AC 211 ms
15,088 KB
testcase_37 AC 425 ms
15,196 KB
testcase_38 AC 444 ms
15,320 KB
testcase_39 AC 762 ms
15,500 KB
testcase_40 AC 800 ms
15,504 KB
testcase_41 AC 792 ms
15,600 KB
testcase_42 AC 612 ms
15,472 KB
testcase_43 AC 821 ms
15,400 KB
testcase_44 AC 344 ms
15,308 KB
testcase_45 AC 798 ms
15,352 KB
testcase_46 AC 166 ms
15,296 KB
testcase_47 AC 385 ms
15,132 KB
testcase_48 AC 297 ms
15,088 KB
testcase_49 AC 344 ms
15,092 KB
testcase_50 AC 396 ms
15,216 KB
testcase_51 AC 473 ms
15,192 KB
testcase_52 AC 459 ms
15,208 KB
testcase_53 AC 705 ms
15,332 KB
testcase_54 AC 214 ms
15,136 KB
testcase_55 AC 113 ms
15,328 KB
testcase_56 AC 574 ms
15,324 KB
testcase_57 AC 403 ms
15,276 KB
testcase_58 AC 88 ms
15,260 KB
testcase_59 AC 87 ms
15,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$N = gets.to_i
$S = gets.strip.split("").map{|s| s == "E" ? 1 : 0}
$A = gets.split(" ").map{|s| s.to_i}
Q = gets.to_i
K = gets.split(" ").map{|s| s.to_i}

def maxEnemy(k)
	maxres = 0
	res = 0
	s = t = sum = 0
	loop {
		while t < $N and sum <= k do
			sum += $A[t]
			res += $S[t]
			t += 1
		end
		if sum <= k then
			maxres = res if res > maxres
			break
		end
		maxres = (res - $S[t-1]) if (res - $S[t-1]) > maxres
		sum -= $A[s]
		res -= $S[s]
		s += 1
	}
	maxres
end

K.each {|k|
	puts maxEnemy(k)
}
0