結果

問題 No.1137 Circles
ユーザー face4
提出日時 2020-08-04 22:38:28
言語 Java
(openjdk 27 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 450 ms / 2,000 ms
+ 921µs
コード長 1,208 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,199 ms
コンパイル使用メモリ 93,312 KB
実行使用メモリ 70,124 KB
最終ジャッジ日時 2026-10-19 07:09:03
合計ジャッジ時間 10,532 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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