結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2016-01-04 08:57:37 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 58 ms / 5,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 2,028 ms |
コンパイル使用メモリ | 77,708 KB |
実行使用メモリ | 50,400 KB |
最終ジャッジ日時 | 2024-06-25 01:14:26 |
合計ジャッジ時間 | 4,175 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
import java.io.*;import java.util.*;import java.math.*;class Main {public static void out (Object o) {System.out.println(o);}public static boolean isPd (int a , int b , int c) {if (a == b || a == c || b == c) return false;return (c < a && a < b) || (b < a && a < c) || (a < c && c < b) || (b < c && c < a);}public static void main (String[] args) throws IOException {BufferedReader br =new BufferedReader(new InputStreamReader(System.in));int n = Integer.parseInt(br.readLine());int[] a = new int[n];String[] line = br.readLine().split(" ");for (int i = 0; i < n; i++) {a[i] = Integer.parseInt(line[i]);}int ans = 0;for (int i = 2; i < n; i++) {ans = isPd(a[i - 2] , a[i - 1] , a[i]) ? ans + 1 : ans;}out(ans);}}