結果

問題 No.1137 Circles
ユーザー 小野寺健小野寺健
提出日時 2021-12-19 21:01:42
言語 Go
(1.22.1)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 13,587 ms
コンパイル使用メモリ 212,392 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-10-13 19:00:47
合計ジャッジ時間 13,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 115 ms
7,924 KB
testcase_02 AC 3 ms
4,352 KB
testcase_03 AC 53 ms
5,608 KB
testcase_04 AC 84 ms
7,920 KB
testcase_05 AC 14 ms
4,348 KB
testcase_06 AC 98 ms
7,916 KB
testcase_07 AC 42 ms
5,596 KB
testcase_08 AC 101 ms
7,912 KB
testcase_09 AC 28 ms
4,348 KB
testcase_10 AC 48 ms
5,600 KB
testcase_11 AC 58 ms
5,600 KB
testcase_12 AC 128 ms
7,956 KB
testcase_13 AC 31 ms
4,352 KB
testcase_14 AC 122 ms
7,936 KB
testcase_15 AC 34 ms
5,580 KB
testcase_16 AC 56 ms
5,668 KB
testcase_17 AC 7 ms
4,352 KB
testcase_18 AC 97 ms
7,916 KB
testcase_19 AC 32 ms
4,348 KB
testcase_20 AC 23 ms
4,348 KB
testcase_21 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"bufio"
	"os"
	"sort"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var N int
	fmt.Fscan(r, &N)
	coord := make([][2]int, N*2)
	for i := 0; i < N; i++ {
		var x, radius int
		fmt.Fscan(r, &x, &radius)
		coord[2*i] = [2]int{x-radius, 1}
		coord[2*i+1] = [2]int{x+radius, -1}
	}
	sort.Slice(coord, func(i, j int) bool {if coord[i][0] < coord[j][0] { return true } else if coord[i][0] > coord[j][0] { return false } else { return coord[i][1] < coord[j][1]} })
	cnt := 0
	maxcnt := -1
	for _, d := range coord {
		cnt += d[1]
		if cnt > maxcnt {
			maxcnt = cnt
		}
	}
	fmt.Fprintln(w, maxcnt)
}
0