結果

問題 No.116 門松列(1)
コンテスト
ユーザー _Clay____
提出日時 2018-10-13 21:42:04
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 520 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 475 ms
コンパイル使用メモリ 196,104 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 06:28:34
合計ジャッジ時間 1,358 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_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();

  println!(
    "{}",
    a.windows(3)
      .filter(|a| (a[0] != a[1] && a[1] != a[2] && a[2] != a[0])
        && (a[1] > if a[0] > a[2] { a[0] } else { a[2] }
          || a[1] < if a[0] > a[2] { a[2] } else { a[0] })).count()
  );
}
0