結果

問題 No.116 門松列(1)
ユーザー _Clay____
提出日時 2018-10-13 21:38:00
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 541 bytes
コンパイル時間 14,673 ms
コンパイル使用メモリ 377,948 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 01:45:54
合計ジャッジ時間 13,048 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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