結果
問題 | No.1884 Sequence |
ユーザー | tenten |
提出日時 | 2023-08-08 11:24:40 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,588 bytes |
コンパイル時間 | 3,652 ms |
コンパイル使用メモリ | 84,940 KB |
実行使用メモリ | 59,816 KB |
最終ジャッジ日時 | 2024-11-08 17:02:29 |
合計ジャッジ時間 | 19,492 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
36,812 KB |
testcase_01 | AC | 58 ms
37,304 KB |
testcase_02 | AC | 47 ms
37,112 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 47 ms
36,912 KB |
testcase_06 | AC | 47 ms
37,068 KB |
testcase_07 | AC | 46 ms
36,780 KB |
testcase_08 | AC | 47 ms
37,232 KB |
testcase_09 | AC | 47 ms
37,324 KB |
testcase_10 | AC | 755 ms
58,652 KB |
testcase_11 | AC | 787 ms
57,168 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 210 ms
45,240 KB |
testcase_15 | AC | 473 ms
57,452 KB |
testcase_16 | AC | 604 ms
56,492 KB |
testcase_17 | AC | 282 ms
49,132 KB |
testcase_18 | AC | 360 ms
56,328 KB |
testcase_19 | AC | 325 ms
50,952 KB |
testcase_20 | AC | 405 ms
53,636 KB |
testcase_21 | AC | 344 ms
47,392 KB |
testcase_22 | AC | 430 ms
53,812 KB |
testcase_23 | AC | 631 ms
56,628 KB |
testcase_24 | AC | 645 ms
56,732 KB |
testcase_25 | AC | 601 ms
59,816 KB |
testcase_26 | AC | 619 ms
59,808 KB |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | AC | 206 ms
45,204 KB |
testcase_30 | AC | 209 ms
45,020 KB |
testcase_31 | AC | 391 ms
52,628 KB |
testcase_32 | AC | 622 ms
57,256 KB |
testcase_33 | AC | 348 ms
56,288 KB |
testcase_34 | AC | 331 ms
56,024 KB |
testcase_35 | AC | 221 ms
45,908 KB |
testcase_36 | AC | 311 ms
54,576 KB |
testcase_37 | AC | 343 ms
55,904 KB |
testcase_38 | AC | 342 ms
55,060 KB |
testcase_39 | AC | 248 ms
46,652 KB |
testcase_40 | AC | 254 ms
48,272 KB |
testcase_41 | AC | 536 ms
56,504 KB |
testcase_42 | AC | 572 ms
57,368 KB |
ソースコード
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(); } }