結果
問題 |
No.467 隠されていたゲーム
|
ユーザー |
![]() |
提出日時 | 2017-03-22 02:52:16 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,357 bytes |
コンパイル時間 | 2,841 ms |
コンパイル使用メモリ | 77,320 KB |
実行使用メモリ | 37,392 KB |
最終ジャッジ日時 | 2024-07-05 09:13:25 |
合計ジャッジ時間 | 4,903 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 10 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int n = Integer.parseInt(str); str = br.readLine(); String[] dstr = str.split(" "); int[] d = new int[n]; for (int i = 0; i < n; i++) d[i] = Integer.parseInt(dstr[i]); str = br.readLine(); String[] coordinate = str.split(" "); int x = Integer.parseInt(coordinate[0]); int y = Integer.parseInt(coordinate[1]); int dst = Math.max(x, y); int[] d_s = Sort(d); if (dst < d_s[n - 1]) System.out.println("2"); else if (dst <= d_s[0]) { boolean flag = false; for (int dist : d_s) { if (dst == dist) { System.out.println("1"); flag = true; break; } } if (!flag) System.out.println("2"); } else { if (dst % d_s[0] == 0) System.out.println(dst / d_s[0]); else System.out.println(dst / d_s[0] + 1); } } private static int[] Sort(int[] num) { int length = num.length; for (int i = 1; i < length - 1; i++) { for (int j = 0; j < length - i; j++) { if (num[j] < num[j + 1]) { int tmpnum = num[j]; num[j] = num[j + 1]; num[j + 1] = tmpnum; } } } return num; } }