結果

問題 No.1884 Sequence
ユーザー tentententen
提出日時 2023-08-08 11:24:40
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,588 bytes
コンパイル時間 2,607 ms
コンパイル使用メモリ 95,416 KB
実行使用メモリ 67,532 KB
最終ジャッジ日時 2024-04-26 04:26:01
合計ジャッジ時間 20,577 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
50,548 KB
testcase_01 AC 52 ms
50,136 KB
testcase_02 AC 52 ms
50,292 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 53 ms
50,572 KB
testcase_06 AC 54 ms
50,300 KB
testcase_07 AC 51 ms
50,260 KB
testcase_08 AC 54 ms
50,808 KB
testcase_09 AC 51 ms
50,600 KB
testcase_10 AC 830 ms
67,532 KB
testcase_11 AC 846 ms
58,788 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 221 ms
45,336 KB
testcase_15 AC 516 ms
55,540 KB
testcase_16 AC 709 ms
57,008 KB
testcase_17 AC 326 ms
50,184 KB
testcase_18 AC 375 ms
56,464 KB
testcase_19 AC 344 ms
50,900 KB
testcase_20 AC 403 ms
52,028 KB
testcase_21 AC 346 ms
48,588 KB
testcase_22 AC 465 ms
53,920 KB
testcase_23 AC 687 ms
56,896 KB
testcase_24 AC 698 ms
58,204 KB
testcase_25 AC 663 ms
61,544 KB
testcase_26 AC 662 ms
61,112 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 197 ms
45,740 KB
testcase_30 AC 213 ms
45,432 KB
testcase_31 AC 411 ms
53,020 KB
testcase_32 AC 666 ms
58,708 KB
testcase_33 AC 363 ms
56,036 KB
testcase_34 AC 373 ms
55,920 KB
testcase_35 AC 211 ms
45,616 KB
testcase_36 AC 333 ms
54,772 KB
testcase_37 AC 362 ms
55,984 KB
testcase_38 AC 362 ms
55,280 KB
testcase_39 AC 253 ms
46,708 KB
testcase_40 AC 265 ms
48,980 KB
testcase_41 AC 597 ms
58,036 KB
testcase_42 AC 671 ms
58,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        ArrayList<Long> list = new ArrayList<>();
        long count = 0;
        for (int i = 0; i < n; i++) {
            long x = sc.nextLong();
            if (x == 0) {
                count++;
            } else {
                list.add(x);
            }
        }
        Collections.sort(list);
        ArrayList<Long> diff = new ArrayList<>();
        for (int i = 0; i < list.size() - 1; i++) {
            diff.add(list.get(i + 1) - list.get(i));
        }
        Collections.sort(diff);
        if (diff.get(0) == 0) {
            if (diff.get(diff.size() - 1) == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            return;
        }
        for (int i = 1; i < diff.size() && count >= 0; i++) {
            if (diff.get(i) % diff.get(0) == 0) {
                count -= diff.get(i) / diff.get(0) - 1;
            } else {
                System.out.println("No");
                return;
            }
        }
        if (count >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0