結果

問題 No.116 門松列(1)
ユーザー Mcpu3Mcpu3
提出日時 2018-06-22 00:54:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 355 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 72,000 KB
実行使用メモリ 55,896 KB
最終ジャッジ日時 2023-09-07 07:24:14
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,572 KB
testcase_01 AC 129 ms
55,564 KB
testcase_02 AC 125 ms
55,804 KB
testcase_03 AC 127 ms
55,696 KB
testcase_04 AC 127 ms
55,708 KB
testcase_05 AC 126 ms
55,652 KB
testcase_06 AC 125 ms
55,384 KB
testcase_07 AC 127 ms
55,704 KB
testcase_08 AC 128 ms
55,612 KB
testcase_09 AC 127 ms
55,592 KB
testcase_10 AC 129 ms
55,580 KB
testcase_11 AC 128 ms
55,784 KB
testcase_12 AC 133 ms
55,372 KB
testcase_13 AC 130 ms
55,480 KB
testcase_14 AC 136 ms
55,392 KB
testcase_15 AC 125 ms
55,796 KB
testcase_16 AC 132 ms
55,368 KB
testcase_17 AC 130 ms
55,664 KB
testcase_18 AC 137 ms
55,828 KB
testcase_19 AC 128 ms
55,628 KB
testcase_20 AC 135 ms
55,400 KB
testcase_21 AC 137 ms
55,896 KB
testcase_22 AC 129 ms
55,368 KB
testcase_23 AC 135 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class no116{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n,i,s=0,a[]=new int[100];
		n=stdIn.nextInt();
		for(i=0;i<n;i++) a[i]=stdIn.nextInt();
		for(i=0;i<n-2;i++) if((a[i]<a[i+1]&&a[i+1]>a[i+2]||a[i]>a[i+1]&&a[i+1]<a[i+2])&&a[i]!=a[i+2]) s++;
		System.out.print(s);
	}
}
0