結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
![]() |
提出日時 | 2016-08-14 11:11:02 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 837 bytes |
コンパイル時間 | 3,149 ms |
コンパイル使用メモリ | 75,872 KB |
実行使用メモリ | 51,976 KB |
最終ジャッジ日時 | 2024-11-07 05:17:56 |
合計ジャッジ時間 | 19,886 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 2 |
other | AC * 17 RE * 12 |
ソースコード
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] x = new int[n]; for(int i=0; i<n; i++) { x[i] = in.nextInt(); } Arrays.sort(x); int diff = x[1] - x[0]; boolean bool = true; for(int i=1; i<n; i++) { if(x[i+1] == x[i]) { bool = false; break; } int temp = x[i+1] - x[i]; if(temp == diff) continue; } if(bool == true) { System.out.println("YES"); } else if(bool == false) { System.out.println("NO"); } in.close(); } }