結果

問題 No.116 門松列(1)
コンテスト
ユーザー _Clay____
提出日時 2018-10-13 21:38:00
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 541 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 698 ms
コンパイル使用メモリ 194,572 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-11 06:28:30
合計ジャッジ時間 1,713 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 result = a
    .windows(3)
    .filter(|a| a[0] != a[1] && a[1] != a[2] && a[2] != a[0])
    .filter(|a| {
      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();

  println!("{}", result);
}
0