結果
| 問題 | No.3684 chokudai_niku.png |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 14:36:20 |
| 言語 | Ruby (4.0.6) |
| 結果 |
AC
|
| 実行時間 | 248 ms / 2,000 ms |
| + 863µs | |
| コード長 | 1,268 bytes |
| 記録 | |
| コンパイル時間 | 9 ms |
| コンパイル使用メモリ | 9,088 KB |
| 実行使用メモリ | 47,316 KB |
| 最終ジャッジ日時 | 2026-09-05 14:36:43 |
| 合計ジャッジ時間 | 15,136 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
コンパイルメッセージ
Main.rb:5: warning: 'frozen_string_literal' is ignored after any tokens Main.rb:26: warning: 'frozen_string_literal' is ignored after any tokens Syntax OK
ソースコード
# frozen_string_literal: true
# This file is expanded by nanacl.
main = -> do # =================================================================
# frozen_string_literal: true
# require "nanacl/array_sum" # (expanded: L25)
in_n, in_m = gets.chomp.split.map(&:to_i)
in_a = gets.chomp.split.map(&:to_i)
in_b = gets.chomp.split.map(&:to_i)
positives = in_a.zip(in_b).map { |a, b| [a - b, 0].max}
max = 0
(in_n - in_m + 1).times do |i|
max = [
max,
positives.sum_in_range((i)..(i+in_m-1))
].max
end
puts max
end # --------------------------------------------------------------------------
# === dependencies -------------------------------------------------------------
# == nanacl/array_sum from main ------------------------------------------------
# frozen_string_literal: true
class Array
def sum_in_range(range)
unless @sums
@sums = [0]
sum = 0
each { |v| @sums << (sum += v) }
end
range_begin = range.begin || 0
if range.end.nil?
@sums[length] - @sums[range_begin]
elsif range.exclude_end?
@sums[range.end] - @sums[range_begin]
else
@sums[range.end + 1] - @sums[range_begin]
end
end
end
# ==============================================================================
main.call