結果
| 問題 | 
                            No.116 門松列(1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             _Clay____
                         | 
                    
| 提出日時 | 2018-10-13 16:34:12 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 664 bytes | 
| コンパイル時間 | 21,317 ms | 
| コンパイル使用メモリ | 400,832 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-25 01:45:37 | 
| 合計ジャッジ時間 | 17,192 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
コンパイルメッセージ
warning: variable does not need to be mutable
  --> src/main.rs:24:12
   |
24 |       let (mut max, mut min) = if v1 < v3 { (v3, v1) } else { (v1, v3) };
   |            ----^^^
   |            |
   |            help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default
warning: variable does not need to be mutable
  --> src/main.rs:24:21
   |
24 |       let (mut max, mut min) = if v1 < v3 { (v3, v1) } else { (v1, v3) };
   |                     ----^^^
   |                     |
   |                     help: remove this `mut`
            
            ソースコード
use std::io;
fn main() {
  let mut buf = String::new();
  io::stdin().read_line(&mut buf).ok();
  let n: usize = buf.trim().parse().ok().unwrap();
  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 i in 0..n - 2 {
    
    let v1 = a[i];
    let v2 = a[i + 1];
    let v3 = a[i + 2];
    if v1 != v3 && v1 != v2 && v2 != v3 {
      let (mut max, mut min) = if v1 < v3 { (v3, v1) } else { (v1, v3) };
      if v2 < min || v2 > max {
        result += 1;
      }
    }
  }
  println!("{}", result);
}
            
            
            
        
            
_Clay____