結果

問題 No.1093 区間の和 / Sum of Range
ユーザー 小野寺健小野寺健
提出日時 2021-11-05 08:52:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 325 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 23,936 KB
最終ジャッジ日時 2024-04-23 16:41:12
合計ジャッジ時間 10,790 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,288 KB
testcase_01 AC 190 ms
16,000 KB
testcase_02 AC 133 ms
13,312 KB
testcase_03 AC 148 ms
19,200 KB
testcase_04 AC 137 ms
18,688 KB
testcase_05 AC 229 ms
16,000 KB
testcase_06 AC 125 ms
15,104 KB
testcase_07 AC 173 ms
15,744 KB
testcase_08 AC 183 ms
22,400 KB
testcase_09 AC 203 ms
14,848 KB
testcase_10 AC 180 ms
19,072 KB
testcase_11 AC 215 ms
16,128 KB
testcase_12 AC 232 ms
19,200 KB
testcase_13 AC 89 ms
12,288 KB
testcase_14 AC 318 ms
16,128 KB
testcase_15 AC 153 ms
15,872 KB
testcase_16 AC 373 ms
18,944 KB
testcase_17 AC 211 ms
14,208 KB
testcase_18 AC 239 ms
15,488 KB
testcase_19 AC 103 ms
13,184 KB
testcase_20 AC 197 ms
13,696 KB
testcase_21 AC 338 ms
16,000 KB
testcase_22 AC 354 ms
19,072 KB
testcase_23 AC 251 ms
13,952 KB
testcase_24 AC 145 ms
18,560 KB
testcase_25 AC 221 ms
16,128 KB
testcase_26 AC 269 ms
19,200 KB
testcase_27 AC 237 ms
16,000 KB
testcase_28 AC 258 ms
18,944 KB
testcase_29 AC 299 ms
23,936 KB
testcase_30 AC 132 ms
13,824 KB
testcase_31 AC 147 ms
15,872 KB
testcase_32 AC 176 ms
16,896 KB
testcase_33 AC 352 ms
19,072 KB
testcase_34 AC 100 ms
12,672 KB
testcase_35 AC 233 ms
14,592 KB
testcase_36 AC 324 ms
22,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split(" ").map{|s| s.to_i}
a = gets.split(" ").map{|s| s.to_i}
Q = gets.to_i
q = []
Q.times {
	q << gets.to_i
}

S = [a[0,K].sum]
0.upto(N-K-1) {|i|
	S << S[-1] - a[i] + a[i+K]
}

S.sort!

q.each {|x|
	if S[0] > x then
		puts 0
	elsif S[-1] <= x then
		puts S.length
	else
		puts S.bsearch_index{|y| y > x}
	end
}
0