結果
問題 | No.467 隠されていたゲーム |
ユーザー | Vir_MeL0 |
提出日時 | 2017-03-22 03:19:14 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 59 ms / 2,000 ms |
コード長 | 1,581 bytes |
コンパイル時間 | 2,581 ms |
コンパイル使用メモリ | 77,500 KB |
実行使用メモリ | 50,460 KB |
最終ジャッジ日時 | 2024-04-15 04:47:35 |
合計ジャッジ時間 | 5,005 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
50,276 KB |
testcase_01 | AC | 57 ms
50,424 KB |
testcase_02 | AC | 57 ms
49,868 KB |
testcase_03 | AC | 57 ms
50,324 KB |
testcase_04 | AC | 56 ms
50,048 KB |
testcase_05 | AC | 57 ms
50,460 KB |
testcase_06 | AC | 56 ms
50,316 KB |
testcase_07 | AC | 56 ms
50,312 KB |
testcase_08 | AC | 56 ms
50,316 KB |
testcase_09 | AC | 58 ms
50,284 KB |
testcase_10 | AC | 56 ms
50,004 KB |
testcase_11 | AC | 58 ms
50,084 KB |
testcase_12 | AC | 58 ms
50,120 KB |
testcase_13 | AC | 57 ms
50,132 KB |
testcase_14 | AC | 57 ms
50,440 KB |
testcase_15 | AC | 57 ms
50,008 KB |
testcase_16 | AC | 56 ms
50,436 KB |
testcase_17 | AC | 57 ms
50,284 KB |
testcase_18 | AC | 56 ms
50,404 KB |
testcase_19 | AC | 56 ms
50,212 KB |
testcase_20 | AC | 56 ms
50,156 KB |
testcase_21 | AC | 56 ms
49,916 KB |
testcase_22 | AC | 56 ms
50,232 KB |
testcase_23 | AC | 55 ms
50,344 KB |
testcase_24 | AC | 59 ms
50,052 KB |
testcase_25 | AC | 58 ms
50,248 KB |
testcase_26 | AC | 57 ms
50,420 KB |
ソースコード
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(Math.abs(x), Math.abs(y)); d = Sort(d); if (dst == 0) System.out.println("0"); else if (dst < d[0]) System.out.println("2"); else if (dst <= d[n - 1]) { boolean flag = false; for (int dist : d) { if (dst == dist) { System.out.println("1"); flag = true; break; } } if (!flag) System.out.println("2"); } else { if (dst % d[n - 1] == 0) System.out.println(dst / d[n - 1]); else System.out.println(dst / d[n - 1] + 1); } } private static int[] Sort(int[] num) { int length = num.length; if (length == 1) return num; else if (length == 2 && num[0] > num[1]) { int tmpnum = num[0]; num[0] = num[1]; num[1] = tmpnum; } else { for (int i = 1; i < length; 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; } }