結果

問題 No.116 門松列(1)
ユーザー FVRChanFVRChan
提出日時 2017-09-24 15:55:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 5,000 ms
コード長 732 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 74,052 KB
実行使用メモリ 56,332 KB
最終ジャッジ日時 2023-09-07 07:14:03
合計ジャッジ時間 6,576 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
55,848 KB
testcase_01 AC 131 ms
55,720 KB
testcase_02 AC 129 ms
55,640 KB
testcase_03 AC 127 ms
55,764 KB
testcase_04 AC 131 ms
55,664 KB
testcase_05 AC 128 ms
55,832 KB
testcase_06 AC 130 ms
55,424 KB
testcase_07 AC 129 ms
55,892 KB
testcase_08 AC 129 ms
55,496 KB
testcase_09 AC 129 ms
55,736 KB
testcase_10 AC 133 ms
55,604 KB
testcase_11 AC 132 ms
55,880 KB
testcase_12 AC 138 ms
55,752 KB
testcase_13 AC 131 ms
55,980 KB
testcase_14 AC 139 ms
56,188 KB
testcase_15 AC 133 ms
55,744 KB
testcase_16 AC 140 ms
55,916 KB
testcase_17 AC 135 ms
56,332 KB
testcase_18 AC 138 ms
55,740 KB
testcase_19 AC 130 ms
55,952 KB
testcase_20 AC 137 ms
55,536 KB
testcase_21 AC 137 ms
56,024 KB
testcase_22 AC 132 ms
55,388 KB
testcase_23 AC 140 ms
55,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
		int n=Integer.parseInt(sc.nextLine());
		int are[]=new int[n];
		for(int i=0;i<n;i++)
			are[i]=sc.nextInt();
		sc.close();
		int counter=0;
		for(int i=0;i<n-2;i++){
			if(JD(are[i],are[i+1],are[i+2]) && JC(are[i],are[i+1],are[i+2])){
				counter++;
			}
		}
		System.out.println(counter);
	}
	private static boolean JC(int a,int b,int c){
		int are[]={a,b,c};
		Arrays.sort(are);
		if(are[1] == a || are[1] == c)return true;
		else return false;
	}
	private static boolean JD(int a,int b,int c){
		if(a==b || a==c || b==c)
			return false;
		else return true;
	}
}
0