結果

問題 No.116 門松列(1)
コンテスト
ユーザー _Clay____
提出日時 2018-10-13 18:44:08
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 636 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,838 ms
コンパイル使用メモリ 195,620 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 06:28:15
合計ジャッジ時間 4,321 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io;

fn main() {
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).ok();

  let mut buf = String::new();
  io::stdin().read_line(&mut buf).ok();
  let a: Vec<u16> = buf
    .trim()
    .split_whitespace()
    .map(|e| e.parse().ok().unwrap())
    .collect();

  let mut result = 0;

  for v in a.windows(3) {
    result += match v {
      [a, b, c] if a > c => match (a, b, c) {
        (a, b, c) if b > a || b < c => 1,
        _ => 0,
      },
      [a, b, c] if a < c => match (a, b, c) {
        (a, b, c) if b > c || b < a => 1,
        _ => 0,
      },
      _ => 0,
    };
  }
  println!("{}", result);
}
0