結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2017-09-24 15:55:02 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 142 ms / 5,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 77,608 KB |
実行使用メモリ | 54,328 KB |
最終ジャッジ日時 | 2024-06-25 01:31:41 |
合計ジャッジ時間 | 6,059 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
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; } }