結果

問題 No.607 開通777年記念
ユーザー nebukuro09nebukuro09
提出日時 2017-12-13 16:48:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 16,560 KB
最終ジャッジ日時 2023-08-21 02:15:46
合計ジャッジ時間 3,155 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,124 KB
testcase_01 AC 78 ms
15,164 KB
testcase_02 AC 77 ms
15,124 KB
testcase_03 AC 78 ms
15,092 KB
testcase_04 AC 81 ms
15,152 KB
testcase_05 AC 77 ms
15,328 KB
testcase_06 AC 80 ms
15,172 KB
testcase_07 AC 122 ms
15,548 KB
testcase_08 AC 80 ms
15,184 KB
testcase_09 AC 86 ms
15,360 KB
testcase_10 AC 82 ms
15,260 KB
testcase_11 AC 512 ms
16,560 KB
testcase_12 AC 552 ms
16,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
a = Array.new(N, 0)

for i in 0...M do
    b = gets.split.map(&:to_i)
    for j in 0...N do
        a[j] += b[j]
    end

    s = 0
    l = 0
    
    for r in 0...N do
        s += a[r]
        while l < r && s > 777 do
            s -= a[l]
            l += 1
        end
        if s == 777 then
            puts "YES"
            exit
        end
    end
end

puts "NO"
0