結果

問題 No.1438 Broken Drawers
ユーザー masashi0217masashi0217
提出日時 2021-04-04 06:18:21
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 33,884 KB
最終ジャッジ日時 2023-08-27 01:30:27
合計ジャッジ時間 6,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,044 KB
testcase_01 AC 76 ms
15,348 KB
testcase_02 AC 73 ms
15,052 KB
testcase_03 WA -
testcase_04 AC 73 ms
15,048 KB
testcase_05 AC 72 ms
15,336 KB
testcase_06 AC 184 ms
33,884 KB
testcase_07 AC 200 ms
32,960 KB
testcase_08 AC 75 ms
15,048 KB
testcase_09 AC 73 ms
15,168 KB
testcase_10 AC 74 ms
15,088 KB
testcase_11 AC 80 ms
15,548 KB
testcase_12 AC 123 ms
20,848 KB
testcase_13 AC 153 ms
25,988 KB
testcase_14 AC 115 ms
20,176 KB
testcase_15 AC 202 ms
32,544 KB
testcase_16 AC 206 ms
32,252 KB
testcase_17 AC 215 ms
32,992 KB
testcase_18 AC 193 ms
32,912 KB
testcase_19 AC 193 ms
33,100 KB
testcase_20 AC 192 ms
33,148 KB
testcase_21 AC 189 ms
32,804 KB
testcase_22 AC 195 ms
33,260 KB
testcase_23 AC 198 ms
33,180 KB
testcase_24 AC 201 ms
33,048 KB
testcase_25 AC 192 ms
33,104 KB
testcase_26 AC 194 ms
33,128 KB
testcase_27 AC 201 ms
33,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
tmp = []
0.upto(n-2) do |j|
    if a[j] < a[j+1]
        if tmp == []
            tmp << j
            tmp << j + 1
        elsif a[j-1] < a[j]
             tmp << j + 1
        elsif a[j-1] > a[j]
            if tmp[-1] == j-1
                tmp << j + 1
            elsif tmp[-1] == j
                tmp << j + 1
            else
                tmp << j
                tmp << j + 1
            end
        end
    else
        if tmp == []
            tmp << j
        elsif a[j-1] < a[j]
            if tmp[-1] == j - 1
                tmp << j + 1
            elsif tmp[-1] != j
                tmp << j
            end
        elsif a[j-1] > a[j]
            if tmp[-1] == j - 1
                tmp << j + 1
            elsif tmp[-1] != j
                tmp << j
            end
        end
    end
end
puts tmp.count
# arr = []
# tmp.each do |k|
#     arr << a[k]
# end
# p arr
0