結果

問題 No.2015 Stair Counter
ユーザー rururun
提出日時 2024-11-10 13:01:29
言語 Swift
(6.0.3)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 2,901 ms
コンパイル使用メモリ 132,340 KB
実行使用メモリ 20,160 KB
最終ジャッジ日時 2024-11-10 13:01:36
合計ジャッジ時間 5,126 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.swift:2:5: warning: immutable value 'i' was never used; consider replacing with '_' or removing it
for i in 1...t{
    ^
    _

ソースコード

diff #

let t = Int(readLine()!)!
for i in 1...t{
    let nm = readLine()!.split(separator: " ").map{Int($0)!}
    let (n,m) = (nm[0],nm[1])
    var A = [0,m] + readLine()!.split(separator: " ").map{Int($0)!}
    
    var f = true
    if n > 1{
    for i in 2...n{
        let a = A[i]-A[i-2]
        if a < 0{
            f = false
        }
        A[i-1] -= a
        if A[i-1] < 0{
            f = false
        }
    }
    }
    if A[n+1] != A[n-1] + A[n]{
        f = false
    }
    if f {
        print("Yes")
    }else{
        print("No")
    }
}
0