結果

問題 No.865 24時間降水量
ユーザー simansiman
提出日時 2022-04-23 03:33:36
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 386 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 15,452 KB
最終ジャッジ日時 2023-09-06 14:41:45
合計ジャッジ時間 8,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
15,076 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 70 ms
15,132 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: assigned but unused variable - sum
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)
Q = gets.to_i

sum = A.sum

def f(idx)
  res = 0

  -23.upto(0) do |d|
    from = idx + d
    to = from + 23
    next if from < 0
    next if to >= N

    sum = 0

    from.upto(to) do |idx|
      sum += A[idx]
    end

    res = sum if res < sum
  end

  res
end

Q.times do
  t, v = gets.split.map(&:to_i)

  A[t - 1] = v

  puts f(t - 1)
end
0