結果

問題 No.116 門松列(1)
ユーザー cra77756176
提出日時 2022-11-30 00:34:02
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 13,866 ms
コンパイル使用メモリ 378,316 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-07 09:02:50
合計ジャッジ時間 13,691 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io;

fn main() {
    io::stdin().read_line(&mut String::new()).ok();
    let mut aa = String::new();
    io::stdin().read_line(&mut aa).ok();
    let aa = aa
        .split_whitespace()
        .map(|n| n.parse::<u64>().unwrap())
        .collect::<Vec<_>>();

    let answer = aa
        .windows(3)
        .filter(|&x| {
            x[1] < x[0] && x[0] < x[2]
                || x[1] > x[0] && x[0] > x[2]
                || x[1] < x[2] && x[2] < x[0]
                || x[1] > x[2] && x[2] > x[0]
        })
        .count();

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