結果
問題 |
No.116 門松列(1)
|
ユーザー |
![]() |
提出日時 | 2017-02-02 23:59:50 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 610 bytes |
コンパイル時間 | 1,876 ms |
コンパイル使用メモリ | 75,344 KB |
実行使用メモリ | 41,744 KB |
最終ジャッジ日時 | 2024-12-24 03:59:25 |
合計ジャッジ時間 | 5,745 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 7 WA * 14 |
ソースコード
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for(int i=0; i<n; i++) { a[i] = in.nextInt(); } int count = 0; for(int i=0; i<n-2; i++) { if((a[i] < a[i+1] && a[i] > a[i+2]) || (a[i+2] < a[i+1] && a[i+2] > a[i])) { count++; } } System.out.println(count); in.close(); } }