結果
問題 | No.1137 Circles |
ユーザー | tenten |
提出日時 | 2023-02-16 16:06:08 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 594 ms / 2,000 ms |
コード長 | 2,608 bytes |
コンパイル時間 | 2,803 ms |
コンパイル使用メモリ | 83,168 KB |
実行使用メモリ | 65,744 KB |
最終ジャッジ日時 | 2023-09-25 20:37:51 |
合計ジャッジ時間 | 11,359 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
49,600 KB |
testcase_01 | AC | 558 ms
64,788 KB |
testcase_02 | AC | 100 ms
52,160 KB |
testcase_03 | AC | 338 ms
61,040 KB |
testcase_04 | AC | 434 ms
63,248 KB |
testcase_05 | AC | 181 ms
55,000 KB |
testcase_06 | AC | 491 ms
63,048 KB |
testcase_07 | AC | 304 ms
59,192 KB |
testcase_08 | AC | 511 ms
63,388 KB |
testcase_09 | AC | 240 ms
57,968 KB |
testcase_10 | AC | 338 ms
60,828 KB |
testcase_11 | AC | 368 ms
61,564 KB |
testcase_12 | AC | 594 ms
65,496 KB |
testcase_13 | AC | 268 ms
56,932 KB |
testcase_14 | AC | 583 ms
65,744 KB |
testcase_15 | AC | 286 ms
58,992 KB |
testcase_16 | AC | 350 ms
61,124 KB |
testcase_17 | AC | 137 ms
53,160 KB |
testcase_18 | AC | 492 ms
63,572 KB |
testcase_19 | AC | 258 ms
56,344 KB |
testcase_20 | AC | 222 ms
57,676 KB |
testcase_21 | AC | 44 ms
49,472 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); PriorityQueue<Place> queue = new PriorityQueue<>(); for (int i = 0; i < n; i++) { int x = sc.nextInt(); int r = sc.nextInt(); queue.add(new Place(1, i, x - r)); queue.add(new Place(0, i, x + r)); } HashSet<Integer> current = new HashSet<>(); int ans = 0; while (queue.size() > 0) { Place x = queue.poll(); if (x.type == 0) { current.remove(x.idx); } else { current.add(x.idx); ans = Math.max(ans, current.size()); } } System.out.println(ans); } static class Place implements Comparable<Place> { int type; int idx; int value; public Place(int type, int idx, int value) { this.type = type; this.idx = idx; this.value = value; } public int compareTo(Place another) { if (value == another.value) { return type - another.type; } else { return value - another.value; } } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }