結果

問題 No.116 門松列(1)
ユーザー _Clay_____Clay____
提出日時 2018-10-08 16:48:02
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 415 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 18:37:54
合計ジャッジ時間 874 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = io.read()
a = {}
scan = string.gmatch(io.read(),"%d+")
for i = 1, n do
  a[i] = scan()
end
result = 0
for i = 1 , n - 2 do
  local v1 = a[i]
  local v2 = a[i+1]
  local v3 = a[i+2]
  if v1 ~= v3 and v1 ~= v2 and v2 ~= v3 then
    local max, min = nil, nil
    if v1 < v3 then max, min = v3, v1 else max, min = v1, v3 end
    if v2 < min or v2 > max then
      result = result + 1
    end
  end
end
print(result)
0