結果
問題 | No.467 隠されていたゲーム |
ユーザー | Grenache |
提出日時 | 2016-12-17 12:06:52 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,565 bytes |
コンパイル時間 | 4,278 ms |
コンパイル使用メモリ | 80,232 KB |
実行使用メモリ | 140,680 KB |
最終ジャッジ日時 | 2024-05-08 04:04:59 |
合計ジャッジ時間 | 10,082 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 103 ms
59,364 KB |
testcase_01 | AC | 124 ms
54,204 KB |
testcase_02 | AC | 114 ms
53,316 KB |
testcase_03 | AC | 117 ms
54,064 KB |
testcase_04 | AC | 122 ms
54,224 KB |
testcase_05 | AC | 117 ms
54,124 KB |
testcase_06 | AC | 123 ms
54,028 KB |
testcase_07 | AC | 116 ms
53,920 KB |
testcase_08 | AC | 122 ms
54,180 KB |
testcase_09 | AC | 116 ms
53,976 KB |
testcase_10 | AC | 110 ms
53,544 KB |
testcase_11 | AC | 123 ms
54,012 KB |
testcase_12 | AC | 106 ms
53,052 KB |
testcase_13 | AC | 117 ms
54,168 KB |
testcase_14 | AC | 111 ms
54,532 KB |
testcase_15 | AC | 118 ms
54,104 KB |
testcase_16 | AC | 126 ms
54,012 KB |
testcase_17 | AC | 126 ms
54,204 KB |
testcase_18 | AC | 384 ms
67,036 KB |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder467 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int[] d = new int[n]; for (int i = 0; i < n; i++) { d[i] = sc.nextInt(); } Arrays.sort(d); int maxd = d[n - 1]; int x = Math.abs(sc.nextInt()); int y = Math.abs(sc.nextInt()); int maxx = Math.max(x, y); if (maxx % maxd == 0) { pr.println(maxx / maxd); return; } else { if (d.length > 1) { int cnt = maxx / maxd; SortedSet<Long> hs = new TreeSet<>(); Queue<Long> hstmp = new ArrayDeque<>(); for (int j = 0, size = d.length; j < size - 1; j++) { hs.add((long)d[j]); } for (int i = 0; i <= cnt; i++) { if (hs.contains((long)(maxx - maxd * (cnt - i)))) { pr.println(cnt + 1); return; } if (hs.last() + d[n - 2] < maxx - maxd * (cnt - i)) { break; } hstmp.clear(); for (long e : hs) { for (int j = 0, size = d.length; j < size - 1; j++) { int e1 = d[j]; hstmp.add(e + e1); } } hs.addAll(hstmp); } } if (x != y) { pr.println(Math.max(1, maxx / maxd) + 1); } else { pr.println(Math.max(1, maxx / maxd) + 1 + 1); } } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }