結果

問題 No.607 開通777年記念
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-01-28 18:25:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,471 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 23,832 KB
最終ジャッジ日時 2023-10-13 20:49:29
合計ジャッジ時間 5,565 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,280 KB
testcase_01 AC 79 ms
15,036 KB
testcase_02 AC 79 ms
15,040 KB
testcase_03 AC 80 ms
15,132 KB
testcase_04 AC 83 ms
15,044 KB
testcase_05 AC 82 ms
15,128 KB
testcase_06 AC 80 ms
15,304 KB
testcase_07 AC 192 ms
17,484 KB
testcase_08 AC 81 ms
15,140 KB
testcase_09 AC 96 ms
15,640 KB
testcase_10 AC 85 ms
15,460 KB
testcase_11 AC 1,450 ms
23,832 KB
testcase_12 AC 1,471 ms
23,824 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
T = Array.new(M + 1){Array.new(N + 1, 0) }
(1 .. M).each do |i|
  d = gets.split.map(&:to_i)
  (1 .. N).each do |j|
    T[i][j] = T[i - 1][j] + d[j - 1]
  end
end

found = (1 .. M).find do |i|
  (1 .. N).each do |j|
    T[i][j] += T[i][j - 1]
  end
  (0 .. N).inject(0) do |r,l|
    r = (r .. N).find do |j|
      T[i][j] - T[i][l] >= 777
    end
    break false if r.nil?
    break true if T[i][r] - T[i][l] == 777
    next r
  end
end
puts found ? :YES : :NO

0