結果
問題 | No.467 隠されていたゲーム |
ユーザー |
|
提出日時 | 2016-12-18 01:28:10 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 140 ms / 2,000 ms |
コード長 | 783 bytes |
コンパイル時間 | 4,212 ms |
コンパイル使用メモリ | 77,888 KB |
実行使用メモリ | 54,476 KB |
最終ジャッジ日時 | 2024-10-04 16:18:05 |
合計ジャッジ時間 | 8,824 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
package yukicoder; import java.util.*; public class Q467 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] d = new long[n]; for (int i = 0; i < n; ++i) { d[i] = sc.nextLong(); } long x = sc.nextLong(); long y = sc.nextLong(); x = Math.abs(x); y = Math.abs(y); Arrays.sort(d); long ans = 0; if (x == 0 && y == 0) { System.out.println(0); return; } if (Math.max(x, y) > 2 * d[n - 1]) { long c = Math.max(x / d[n - 1], y / d[n - 1]); x = Math.max(0, x - d[n - 1] * (c - 1)); y = Math.max(0, y - d[n - 1] * (c - 1)); ans += c - 1; } ans += 2; for (int i = 0; i < n; ++i) { if (Math.max(x, y) == d[i]) { --ans; break; } } System.out.println(ans); } }