結果

問題 No.1137 Circles
ユーザー face4face4
提出日時 2020-08-04 22:38:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 593 ms / 2,000 ms
コード長 1,208 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 76,268 KB
実行使用メモリ 58,488 KB
最終ジャッジ日時 2023-10-13 00:18:13
合計ジャッジ時間 11,544 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
33,444 KB
testcase_01 AC 530 ms
47,664 KB
testcase_02 AC 75 ms
35,208 KB
testcase_03 AC 331 ms
44,700 KB
testcase_04 AC 425 ms
46,512 KB
testcase_05 AC 177 ms
39,768 KB
testcase_06 AC 462 ms
46,892 KB
testcase_07 AC 298 ms
43,956 KB
testcase_08 AC 490 ms
46,752 KB
testcase_09 AC 230 ms
42,400 KB
testcase_10 AC 315 ms
44,440 KB
testcase_11 AC 339 ms
44,492 KB
testcase_12 AC 593 ms
48,420 KB
testcase_13 AC 228 ms
42,736 KB
testcase_14 AC 558 ms
47,996 KB
testcase_15 AC 270 ms
45,476 KB
testcase_16 AC 339 ms
58,488 KB
testcase_17 AC 142 ms
38,892 KB
testcase_18 AC 476 ms
46,676 KB
testcase_19 AC 249 ms
43,120 KB
testcase_20 AC 212 ms
42,240 KB
testcase_21 AC 40 ms
33,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

enum type {in, out};

class Point implements Comparable<Point>{
    int x;
    type t;
    Point(int x, type t){
        this.x = x;
        this.t = t;
    }
    @Override
    public int compareTo(Point p){
        if(this.x != p.x){
            return x-p.x;
        }else{
            return this.t == type.out ? -1 : 1;
        }
    }
}
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        ArrayList<Point> a = new ArrayList<Point>(2*n);
        for(int i = 0; i < n; i++){
            String[] line = br.readLine().split(" ");
            int x = Integer.parseInt(line[0]);
            int r = Integer.parseInt(line[1]);
            a.add(new Point(x-r, type.in));
            a.add(new Point(x+r, type.out));
        }
        Collections.sort(a);
        int ret = 0, now = 0;
        for(int i = 0; i < 2*n; i++){
            now += a.get(i).t==type.in ? 1 : -1;
            ret = Math.max(ret, now);
        }
        System.out.println(ret);
    }
}
0