結果

問題 No.406 鴨等間隔の法則
ユーザー crazybbb3crazybbb3
提出日時 2016-12-05 22:13:23
言語 Java19
(openjdk 21)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 1,978 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 57,108 KB
最終ジャッジ日時 2023-09-21 18:25:53
合計ジャッジ時間 9,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 174 ms
55,224 KB
testcase_01 AC 42 ms
49,948 KB
testcase_02 AC 42 ms
49,608 KB
testcase_03 AC 42 ms
49,932 KB
testcase_04 AC 242 ms
57,108 KB
testcase_05 AC 155 ms
56,196 KB
testcase_06 AC 171 ms
55,752 KB
testcase_07 AC 164 ms
55,672 KB
testcase_08 AC 218 ms
56,220 KB
testcase_09 AC 225 ms
57,088 KB
testcase_10 AC 179 ms
55,784 KB
testcase_11 AC 200 ms
56,600 KB
testcase_12 AC 204 ms
56,784 KB
testcase_13 AC 190 ms
56,124 KB
testcase_14 AC 245 ms
56,300 KB
testcase_15 AC 92 ms
52,512 KB
testcase_16 AC 90 ms
52,996 KB
testcase_17 AC 86 ms
52,336 KB
testcase_18 AC 87 ms
50,480 KB
testcase_19 AC 94 ms
52,776 KB
testcase_20 AC 124 ms
53,316 KB
testcase_21 AC 115 ms
53,308 KB
testcase_22 AC 145 ms
56,208 KB
testcase_23 AC 187 ms
56,240 KB
testcase_24 AC 200 ms
56,700 KB
testcase_25 AC 254 ms
56,924 KB
testcase_26 AC 254 ms
56,860 KB
testcase_27 AC 202 ms
56,216 KB
testcase_28 AC 200 ms
55,980 KB
testcase_29 AC 251 ms
56,840 KB
testcase_30 AC 253 ms
56,832 KB
testcase_31 AC 221 ms
56,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        int[] x = nia(n);
        Arrays.sort(x);
        int d = x[1] - x[0];
        if (d == 0) {
            out.println("NO");
            return;
        }
        for (int i = 1; i < n - 1; i++) {
            if (x[i + 1] - x[i] != d) {
                out.println("NO");
                return;
            }
        }
        out.println("YES");
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0