結果
問題 | No.116 門松列(1) |
ユーザー |
|
提出日時 | 2020-04-02 20:46:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 16,479 ms |
コンパイル使用メモリ | 377,976 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 15:17:31 |
合計ジャッジ時間 | 15,670 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
use std::io::*;fn main() {let mut s: String = String::new();std::io::stdin().read_to_string(&mut s).ok();let mut itr = s.trim().split_whitespace();let n: usize = itr.next().unwrap().parse().unwrap();let a: Vec<usize> = (0..n).map(|_| itr.next().unwrap().parse().unwrap()).collect();let mut ans = 0;for i in 1..n - 1 {if (a[i - 1] < a[i] && a[i] > a[i + 1]) || (a[i - 1] > a[i] && a[i] < a[i + 1]) {if a[i - 1] != a[i + 1] {ans += 1;}}}println!("{}", ans);}