結果
| 問題 |
No.116 門松列(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-15 21:04:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 5,000 ms |
| コード長 | 471 bytes |
| コンパイル時間 | 3,878 ms |
| コンパイル使用メモリ | 78,028 KB |
| 実行使用メモリ | 41,580 KB |
| 最終ジャッジ日時 | 2024-06-25 01:04:46 |
| 合計ジャッジ時間 | 7,527 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.util.Scanner;
public class N116 {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
int n = sca.nextInt();
int[] a = new int[n];
int c = 0;
for (int i = 0; i < n; i++)
a[i] = sca.nextInt();
for (int i = 0; i < n - 2; i++) {
int x = a[i];
int y = a[i + 1];
int z = a[i + 2];
if (x < y && y > z && z != x)
c++;
else if (x > y && y < z && x != z)
c++;
}
System.out.println(c);
}
}