結果

問題 No.607 開通777年記念
ユーザー nebukuro09nebukuro09
提出日時 2017-12-13 16:48:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 641 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-05-08 07:49:38
合計ジャッジ時間 3,251 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
12,160 KB
testcase_01 AC 97 ms
12,416 KB
testcase_02 AC 95 ms
12,288 KB
testcase_03 AC 97 ms
12,288 KB
testcase_04 AC 96 ms
12,288 KB
testcase_05 AC 97 ms
12,288 KB
testcase_06 AC 97 ms
12,160 KB
testcase_07 AC 138 ms
12,800 KB
testcase_08 AC 94 ms
12,160 KB
testcase_09 AC 105 ms
12,416 KB
testcase_10 AC 96 ms
12,288 KB
testcase_11 AC 590 ms
13,568 KB
testcase_12 AC 641 ms
13,568 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