結果

問題 No.1884 Sequence
ユーザー ks2mks2m
提出日時 2022-03-25 22:55:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 995 bytes
コンパイル時間 3,671 ms
コンパイル使用メモリ 77,492 KB
実行使用メモリ 72,512 KB
最終ジャッジ日時 2024-04-22 07:45:03
合計ジャッジ時間 35,334 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,304 KB
testcase_01 AC 129 ms
54,204 KB
testcase_02 AC 122 ms
52,952 KB
testcase_03 AC 131 ms
54,216 KB
testcase_04 AC 132 ms
54,312 KB
testcase_05 AC 135 ms
54,296 KB
testcase_06 AC 132 ms
54,224 KB
testcase_07 AC 133 ms
54,156 KB
testcase_08 AC 132 ms
54,188 KB
testcase_09 AC 131 ms
54,280 KB
testcase_10 AC 1,046 ms
70,792 KB
testcase_11 AC 1,059 ms
71,212 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 637 ms
59,472 KB
testcase_15 AC 895 ms
70,200 KB
testcase_16 AC 1,021 ms
71,836 KB
testcase_17 WA -
testcase_18 AC 826 ms
70,784 KB
testcase_19 AC 864 ms
64,744 KB
testcase_20 AC 874 ms
68,348 KB
testcase_21 AC 776 ms
66,956 KB
testcase_22 AC 862 ms
69,988 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,002 ms
71,040 KB
testcase_26 AC 1,050 ms
70,956 KB
testcase_27 AC 688 ms
65,480 KB
testcase_28 AC 738 ms
65,964 KB
testcase_29 AC 689 ms
66,124 KB
testcase_30 AC 699 ms
65,556 KB
testcase_31 AC 825 ms
64,772 KB
testcase_32 AC 1,003 ms
71,140 KB
testcase_33 AC 866 ms
70,772 KB
testcase_34 AC 870 ms
70,544 KB
testcase_35 AC 667 ms
65,820 KB
testcase_36 AC 880 ms
70,852 KB
testcase_37 AC 875 ms
71,004 KB
testcase_38 AC 903 ms
71,164 KB
testcase_39 AC 708 ms
66,568 KB
testcase_40 AC 761 ms
67,204 KB
testcase_41 AC 972 ms
70,776 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 max = 0;
		long min = 9;
		long z = 0;
		long mind = 1000000000000000000L;
		for (int i = 0; i < n; i++) {
			if (a[i] == 0) {
				z++;
			} else {
				max = Math.max(max, a[i]);
				min = Math.min(min, a[i]);
				if (i > 0) {
					mind = Math.min(mind, a[i] - a[i - 1]);
				}
			}
		}

		for (int i = (int) z + 1; i < n; i++) {
			long d = a[i] - a[i - 1];
			if (mind == 0) {
				if (d > 0) {
					System.out.println("No");
					return;
				}
			} else if (d % mind != 0 || d == 0) {
				System.out.println("No");
				return;
			} else {
				z -= d / mind - 1;
				if (z < 0) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}
0