結果

問題 No.1199 お菓子配り-2
ユーザー laneguelanegue
提出日時 2020-08-28 22:02:10
言語 Ruby
(3.2.2)
結果
AC  
実行時間 389 ms / 1,000 ms
コード長 366 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 11,160 KB
実行使用メモリ 16,740 KB
最終ジャッジ日時 2023-08-08 22:42:49
合計ジャッジ時間 16,891 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
15,240 KB
testcase_01 AC 69 ms
15,316 KB
testcase_02 AC 66 ms
15,032 KB
testcase_03 AC 133 ms
15,744 KB
testcase_04 AC 238 ms
15,936 KB
testcase_05 AC 77 ms
15,384 KB
testcase_06 AC 81 ms
15,456 KB
testcase_07 AC 152 ms
15,688 KB
testcase_08 AC 184 ms
15,916 KB
testcase_09 AC 137 ms
15,848 KB
testcase_10 AC 84 ms
15,400 KB
testcase_11 AC 120 ms
15,512 KB
testcase_12 AC 124 ms
15,716 KB
testcase_13 AC 86 ms
15,356 KB
testcase_14 AC 83 ms
15,588 KB
testcase_15 AC 81 ms
15,388 KB
testcase_16 AC 181 ms
16,056 KB
testcase_17 AC 121 ms
15,480 KB
testcase_18 AC 182 ms
15,748 KB
testcase_19 AC 101 ms
15,624 KB
testcase_20 AC 272 ms
16,128 KB
testcase_21 AC 195 ms
15,956 KB
testcase_22 AC 135 ms
15,688 KB
testcase_23 AC 159 ms
15,796 KB
testcase_24 AC 193 ms
15,680 KB
testcase_25 AC 87 ms
15,612 KB
testcase_26 AC 212 ms
15,948 KB
testcase_27 AC 183 ms
15,804 KB
testcase_28 AC 339 ms
16,520 KB
testcase_29 AC 333 ms
16,640 KB
testcase_30 AC 331 ms
16,500 KB
testcase_31 AC 374 ms
16,544 KB
testcase_32 AC 386 ms
16,680 KB
testcase_33 AC 389 ms
16,412 KB
testcase_34 AC 385 ms
16,736 KB
testcase_35 AC 389 ms
16,524 KB
testcase_36 AC 386 ms
16,516 KB
testcase_37 AC 384 ms
16,524 KB
testcase_38 AC 333 ms
16,712 KB
testcase_39 AC 328 ms
16,424 KB
testcase_40 AC 334 ms
16,676 KB
testcase_41 AC 340 ms
16,676 KB
testcase_42 AC 329 ms
16,548 KB
testcase_43 AC 334 ms
16,528 KB
testcase_44 AC 340 ms
16,428 KB
testcase_45 AC 341 ms
16,644 KB
testcase_46 AC 332 ms
16,740 KB
testcase_47 AC 337 ms
16,408 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: assigned but unused variable - prev
Syntax OK

ソースコード

diff #

N,M=gets.split.map(&:to_i)
h=[]
N.times{
    h<<gets.split.inject(0){|r,i|r+i.to_i}
}
warn h.inspect
r=0
f=true
prev=0
N.times{|i|
    if f
        if (i==0||h[i-1]<h[i])&&(i==N-1||h[i]>h[i+1])
            r+=h[i]
            f=false
        end
    else
        if h[i-1]>h[i]&&i<N-1&&h[i]<h[i+1]
            r-=h[i]
            f=true
        end
    end
}
puts r
0