結果
問題 | No.1884 Sequence |
ユーザー | tenten |
提出日時 | 2023-08-08 11:26:15 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,689 bytes |
コンパイル時間 | 2,837 ms |
コンパイル使用メモリ | 85,284 KB |
実行使用メモリ | 59,836 KB |
最終ジャッジ日時 | 2024-11-08 17:04:00 |
合計ジャッジ時間 | 18,860 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
36,920 KB |
testcase_01 | AC | 50 ms
37,032 KB |
testcase_02 | AC | 52 ms
36,792 KB |
testcase_03 | AC | 51 ms
37,220 KB |
testcase_04 | AC | 50 ms
37,212 KB |
testcase_05 | AC | 50 ms
37,052 KB |
testcase_06 | AC | 50 ms
37,116 KB |
testcase_07 | AC | 49 ms
37,344 KB |
testcase_08 | AC | 50 ms
36,812 KB |
testcase_09 | AC | 49 ms
37,284 KB |
testcase_10 | AC | 790 ms
57,204 KB |
testcase_11 | AC | 840 ms
57,452 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 206 ms
45,016 KB |
testcase_15 | AC | 473 ms
57,496 KB |
testcase_16 | AC | 674 ms
57,800 KB |
testcase_17 | AC | 297 ms
49,156 KB |
testcase_18 | AC | 374 ms
55,884 KB |
testcase_19 | AC | 337 ms
50,732 KB |
testcase_20 | AC | 411 ms
52,056 KB |
testcase_21 | AC | 352 ms
49,256 KB |
testcase_22 | AC | 447 ms
54,088 KB |
testcase_23 | AC | 670 ms
56,984 KB |
testcase_24 | AC | 675 ms
56,608 KB |
testcase_25 | AC | 667 ms
59,836 KB |
testcase_26 | AC | 655 ms
59,728 KB |
testcase_27 | AC | 190 ms
44,648 KB |
testcase_28 | AC | 214 ms
45,432 KB |
testcase_29 | AC | 208 ms
45,320 KB |
testcase_30 | AC | 221 ms
45,468 KB |
testcase_31 | AC | 418 ms
53,244 KB |
testcase_32 | AC | 620 ms
57,180 KB |
testcase_33 | AC | 349 ms
55,944 KB |
testcase_34 | AC | 367 ms
56,632 KB |
testcase_35 | AC | 206 ms
45,828 KB |
testcase_36 | AC | 338 ms
54,800 KB |
testcase_37 | AC | 361 ms
56,148 KB |
testcase_38 | AC | 346 ms
55,756 KB |
testcase_39 | AC | 258 ms
46,796 KB |
testcase_40 | AC | 262 ms
48,412 KB |
testcase_41 | AC | 609 ms
56,488 KB |
testcase_42 | AC | 599 ms
58,108 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); } } if (list.size() <= 1) { System.out.println("Yes"); return; } 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(); } }