結果
問題 | No.1884 Sequence |
ユーザー |
![]() |
提出日時 | 2022-03-25 23:02:58 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,027 bytes |
コンパイル時間 | 2,323 ms |
コンパイル使用メモリ | 77,708 KB |
実行使用メモリ | 60,420 KB |
最終ジャッジ日時 | 2024-10-14 07:09:30 |
合計ジャッジ時間 | 32,084 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 13 |
ソースコード
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 = sc.nextInt();long[] a = new long[n];for (int i = 0; i < n; i++) {a[i] = sc.nextLong();}sc.close();Arrays.sort(a);long z = 0;long mind = 1000000000000000000L;for (int i = 0; i < n; i++) {if (a[i] == 0) {z++;} else {if (i > 0) {mind = Math.min(mind, a[i] - a[i - 1]);}}}if (mind == 0) {System.out.println("Yes");return;}for (int i = 1; i <= n; i++) {if (mind % i == 0 && judge(n, a, z, mind / i)) {System.out.println("Yes");return;}}System.out.println("No");}static boolean judge(int n, long[] a, long z, long mind) {for (int i = (int) z + 1; i < n; i++) {long d = a[i] - a[i - 1];if (d % mind != 0) {return false;} else {z -= d / mind - 1;if (z < 0) {return false;}}}return true;}}