結果
問題 | No.1265 Balloon Survival |
ユーザー | tenten |
提出日時 | 2020-10-26 09:12:36 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,637 bytes |
コンパイル時間 | 5,533 ms |
コンパイル使用メモリ | 79,632 KB |
実行使用メモリ | 81,596 KB |
最終ジャッジ日時 | 2023-09-29 02:28:53 |
合計ジャッジ時間 | 16,204 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
55,796 KB |
testcase_01 | AC | 125 ms
56,144 KB |
testcase_02 | AC | 125 ms
55,520 KB |
testcase_03 | AC | 127 ms
55,732 KB |
testcase_04 | AC | 127 ms
55,948 KB |
testcase_05 | AC | 130 ms
55,828 KB |
testcase_06 | AC | 127 ms
55,768 KB |
testcase_07 | AC | 136 ms
53,736 KB |
testcase_08 | AC | 128 ms
55,944 KB |
testcase_09 | AC | 127 ms
55,796 KB |
testcase_10 | AC | 127 ms
55,824 KB |
testcase_11 | AC | 133 ms
56,024 KB |
testcase_12 | AC | 129 ms
56,156 KB |
testcase_13 | AC | 125 ms
55,844 KB |
testcase_14 | AC | 284 ms
59,608 KB |
testcase_15 | AC | 275 ms
58,496 KB |
testcase_16 | AC | 213 ms
58,092 KB |
testcase_17 | AC | 467 ms
66,024 KB |
testcase_18 | AC | 224 ms
57,972 KB |
testcase_19 | AC | 222 ms
58,012 KB |
testcase_20 | AC | 284 ms
59,732 KB |
testcase_21 | AC | 341 ms
63,640 KB |
testcase_22 | AC | 312 ms
59,036 KB |
testcase_23 | AC | 304 ms
59,096 KB |
testcase_24 | AC | 680 ms
81,596 KB |
testcase_25 | AC | 670 ms
80,608 KB |
testcase_26 | AC | 671 ms
80,804 KB |
testcase_27 | AC | 681 ms
80,816 KB |
testcase_28 | AC | 679 ms
80,800 KB |
testcase_29 | AC | 667 ms
80,928 KB |
testcase_30 | AC | 682 ms
80,812 KB |
testcase_31 | AC | 703 ms
80,616 KB |
testcase_32 | AC | 669 ms
81,404 KB |
testcase_33 | AC | 707 ms
80,512 KB |
testcase_34 | AC | 139 ms
55,952 KB |
testcase_35 | WA | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] xs = new int[n]; int[] ys = new int[n]; for (int i = 0; i < n; i++) { xs[i] = sc.nextInt(); ys[i] = sc.nextInt(); } PriorityQueue<Unit> queue = new PriorityQueue<>(); for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { queue.add(new Unit(i, j, xs[i] - xs[j], ys[i] - ys[j])); } } int count = 0; boolean[] used = new boolean[n]; while (queue.size() > 0) { Unit u = queue.poll(); if (used[u.left] || used[u.right]) { continue; } if (u.left == 0) { used[u.right] = true; count++; } else { used[u.left] = true; used[u.right] = true; } } System.out.println(count); } static class Unit implements Comparable<Unit> { int left; int right; double dist; public Unit(int left, int right, int x, int y) { this.left = left; this.right = right; dist = Math.pow(x, 2) + Math.pow(y, 2); } public int compareTo(Unit another) { if (dist == another.dist) { return 0; } else if (dist < another.dist) { return -1; } else { return 1; } } } }