結果

問題 No.607 開通777年記念
ユーザー バカらっく
提出日時 2018-06-13 10:00:49
言語 Swift
(6.0.3)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 1,033 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 130,812 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-11-30 12:32:05
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

class Proc {

    public func doProc() {
        let inpt = readLine()!.split(separator: " ").map{ Int($0)! }

        let cargoCount = inpt[0]
        let stCount = inpt[1]

        var cargo = (0..<cargoCount).map { (num) in
            return 0
        }
        var isValid = false
        for _ in 0..<stCount {
            var total = 0
            let dat = readLine()!.split(separator: " ").map{ Int($0)! }
            var from = 0
            for j in 0..<cargoCount {
                cargo[j] += dat[j]
                if cargo[j] > 777 {
                    from = j + 1
                    total = 0
                } else {
                    total += cargo[j]
                    while total > 777 {
                        total -= cargo[from]
                        from += 1
                    }
                }
                isValid = isValid || total == 777
            }
        }

        var ans = "NO"
        if isValid {
            ans = "YES"
        }
        print(ans)
    }

}

Proc().doProc()
0