結果

問題 No.1884 Sequence
ユーザー ks2mks2m
提出日時 2022-03-25 23:02:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,027 bytes
コンパイル時間 2,331 ms
コンパイル使用メモリ 77,816 KB
実行使用メモリ 71,680 KB
最終ジャッジ日時 2024-04-22 07:54:56
合計ジャッジ時間 34,759 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,172 KB
testcase_01 AC 133 ms
54,292 KB
testcase_02 AC 133 ms
54,200 KB
testcase_03 AC 131 ms
53,948 KB
testcase_04 AC 132 ms
54,104 KB
testcase_05 AC 132 ms
54,212 KB
testcase_06 AC 119 ms
52,752 KB
testcase_07 AC 133 ms
54,092 KB
testcase_08 AC 131 ms
53,880 KB
testcase_09 WA -
testcase_10 AC 1,041 ms
71,012 KB
testcase_11 AC 1,058 ms
71,292 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 653 ms
59,460 KB
testcase_15 AC 908 ms
70,316 KB
testcase_16 AC 1,028 ms
70,572 KB
testcase_17 WA -
testcase_18 AC 930 ms
70,728 KB
testcase_19 AC 839 ms
65,412 KB
testcase_20 AC 861 ms
68,176 KB
testcase_21 AC 776 ms
65,972 KB
testcase_22 AC 887 ms
69,852 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 973 ms
70,868 KB
testcase_26 AC 1,025 ms
71,156 KB
testcase_27 AC 692 ms
66,304 KB
testcase_28 AC 736 ms
64,880 KB
testcase_29 AC 720 ms
66,484 KB
testcase_30 AC 683 ms
67,004 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 873 ms
70,444 KB
testcase_34 AC 871 ms
70,808 KB
testcase_35 AC 770 ms
65,956 KB
testcase_36 AC 910 ms
70,504 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 1,035 ms
70,372 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 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;
	}
}
0