結果

問題 No.1137 Circles
ユーザー RISE70226821RISE70226821
提出日時 2020-07-31 15:41:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 792 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 74,744 KB
実行使用メモリ 65,432 KB
最終ジャッジ日時 2023-09-20 15:58:53
合計ジャッジ時間 14,420 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,708 KB
testcase_01 AC 729 ms
65,012 KB
testcase_02 AC 200 ms
58,572 KB
testcase_03 AC 536 ms
60,308 KB
testcase_04 AC 607 ms
62,552 KB
testcase_05 AC 321 ms
60,324 KB
testcase_06 AC 682 ms
64,644 KB
testcase_07 AC 508 ms
60,320 KB
testcase_08 AC 674 ms
64,892 KB
testcase_09 AC 416 ms
60,348 KB
testcase_10 AC 507 ms
60,704 KB
testcase_11 AC 532 ms
60,828 KB
testcase_12 AC 792 ms
65,432 KB
testcase_13 AC 434 ms
60,784 KB
testcase_14 AC 764 ms
65,116 KB
testcase_15 AC 459 ms
60,660 KB
testcase_16 AC 539 ms
62,540 KB
testcase_17 AC 258 ms
60,380 KB
testcase_18 AC 691 ms
64,016 KB
testcase_19 AC 442 ms
60,648 KB
testcase_20 AC 405 ms
60,472 KB
testcase_21 AC 124 ms
55,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		int[] R = new int[N];
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		
		// 円の左端、右端配列を作成
		int[] left = new int[N];
		int[] right = new int[N];
		for(int i = 0; i < N; i++){
			left[i] = X[i] - R[i];
			right[i] = X[i] + R[i];
		}
		Arrays.sort(left);
		Arrays.sort(right);
		
		// 重なり合う円のカウント
		int circle = 0;
		int max = 0;
		int indexL = 0;
		int indexR = 0;
		while(indexL < N && indexR < N){
			if(indexL == N){
				circle--;
				indexR++;
			}
			else if(indexR == N){
				circle++;
				indexL++;
			}
			else if(left[indexL] < right[indexR]){
				circle++;
				indexL++;
			}
			else{
				circle--;
				indexR++;
			}
			
			if(max < circle){
			  max = circle;
			}
		}
		
		
		// 出力
		System.out.println(max);
	}

}
0