結果

問題 No.116 門松列(1)
ユーザー _Clay____
提出日時 2018-10-13 17:13:42
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 22,806 ms
コンパイル使用メモリ 379,012 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 01:44:44
合計ジャッジ時間 17,611 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 mut result = 0;

  for v in a.windows(3) {
    if v[0] != v[1] && v[1] != v[2] && v[2] != v[0] {
      let &max = v.iter().max().unwrap();
      let &min = v.iter().min().unwrap();

      if v[1] == max || v[1] == min {
        result += 1;
      }
    }
  }
  println!("{}", result);
}
0