結果
問題 | No.406 鴨等間隔の法則 |
ユーザー | denderaKawazu |
提出日時 | 2018-03-21 20:12:21 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 148 ms / 2,000 ms |
コード長 | 3,219 bytes |
コンパイル時間 | 1,937 ms |
コンパイル使用メモリ | 78,544 KB |
実行使用メモリ | 40,404 KB |
最終ジャッジ日時 | 2024-07-07 12:22:23 |
合計ジャッジ時間 | 6,556 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
38,992 KB |
testcase_01 | AC | 54 ms
36,864 KB |
testcase_02 | AC | 52 ms
36,744 KB |
testcase_03 | AC | 52 ms
36,368 KB |
testcase_04 | AC | 135 ms
39,368 KB |
testcase_05 | AC | 99 ms
39,008 KB |
testcase_06 | AC | 104 ms
39,136 KB |
testcase_07 | AC | 101 ms
39,288 KB |
testcase_08 | AC | 133 ms
39,312 KB |
testcase_09 | AC | 143 ms
39,404 KB |
testcase_10 | AC | 110 ms
39,244 KB |
testcase_11 | AC | 133 ms
39,176 KB |
testcase_12 | AC | 120 ms
39,648 KB |
testcase_13 | AC | 115 ms
39,576 KB |
testcase_14 | AC | 139 ms
39,848 KB |
testcase_15 | AC | 59 ms
36,524 KB |
testcase_16 | AC | 78 ms
37,368 KB |
testcase_17 | AC | 58 ms
36,924 KB |
testcase_18 | AC | 64 ms
37,132 KB |
testcase_19 | AC | 74 ms
37,904 KB |
testcase_20 | AC | 84 ms
38,936 KB |
testcase_21 | AC | 92 ms
38,672 KB |
testcase_22 | AC | 91 ms
39,548 KB |
testcase_23 | AC | 116 ms
39,256 KB |
testcase_24 | AC | 122 ms
39,184 KB |
testcase_25 | AC | 140 ms
39,956 KB |
testcase_26 | AC | 143 ms
40,404 KB |
testcase_27 | AC | 103 ms
39,272 KB |
testcase_28 | AC | 100 ms
38,800 KB |
testcase_29 | AC | 148 ms
39,896 KB |
testcase_30 | AC | 139 ms
39,084 KB |
testcase_31 | AC | 138 ms
39,800 KB |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.util.NoSuchElementException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastScanner in = new FastScanner(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } static class Task { public void solve(int testNumber, FastScanner in, PrintWriter out) { final int n = in.nextInt(); int[] x = new int[n]; for (int i = 0; i < n; i++) x[i] = in.nextInt(); Arrays.sort(x); int dx = x[1] - x[0]; if (dx == 0) { out.println("NO"); return; } for (int i = 1; i < n; i++) { if (x[i] - x[i - 1] != dx) { out.println("NO"); return; } } out.println("YES"); } } static class FastScanner { private InputStream in; private byte[] buffer; private int p; private int bufLen; public FastScanner(InputStream in) { this.in = in; buffer = new byte[1024]; } private boolean hasNextByte() { if (p < bufLen) return true; p = 0; try { bufLen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } return (bufLen > 0); } private int readByte() { if (hasNextByte()) return buffer[p++]; return -1; } private static boolean isPrintableChar(int c) { return (c >= 33 && c <= 126); } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[p])) p++; return hasNextByte(); } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || b > '9') throw new NumberFormatException(); while (true) { if (b >= '0' && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } } }