結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2016-07-02 14:02:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 138 ms / 5,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 2,192 ms |
コンパイル使用メモリ | 74,376 KB |
実行使用メモリ | 41,644 KB |
最終ジャッジ日時 | 2024-06-25 01:18:49 |
合計ジャッジ時間 | 5,987 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import java.util.Scanner;public class Main{static boolean check(int x){if(a[x+1]>a[x] && a[x+1]>a[x+2] || a[x+1]<a[x] && a[x+1]<a[x+2]) return true;return false;}static int[] a;public static void main(String[] args){Scanner sc=new Scanner(System.in);int n=sc.nextInt();a=new int[n];for(int i=0;i<n;i++) a[i]=sc.nextInt();int ans=0;for(int i=0;i+2<n;i++) if(a[i]!=a[i+1] && a[i+1]!=a[i+2] && a[i]!=a[i+2] && check(i)) ans++;System.out.println(ans);}}