結果
問題 | No.116 門松列(1) |
ユーザー | matsuyoshi30 |
提出日時 | 2017-02-02 23:58:40 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 608 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 73,136 KB |
実行使用メモリ | 58,204 KB |
最終ジャッジ日時 | 2023-08-25 18:10:08 |
合計ジャッジ時間 | 6,188 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 117 ms
55,760 KB |
testcase_05 | AC | 125 ms
55,680 KB |
testcase_06 | AC | 120 ms
55,752 KB |
testcase_07 | WA | - |
testcase_08 | AC | 122 ms
55,768 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 127 ms
56,068 KB |
ソースコード
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] && a[i+2] > a[i])) { count++; } } System.out.println(count); in.close(); } }