結果

問題 No.1265 Balloon Survival
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-28 18:31:09
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 1,023 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 2,828 ms
コンパイル使用メモリ 162,320 KB
実行使用メモリ 42,632 KB
最終ジャッジ日時 2023-10-14 17:30:00
合計ジャッジ時間 16,021 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 70 ms
8,124 KB
testcase_15 AC 50 ms
7,076 KB
testcase_16 AC 18 ms
4,768 KB
testcase_17 AC 436 ms
24,012 KB
testcase_18 AC 26 ms
5,464 KB
testcase_19 AC 20 ms
4,956 KB
testcase_20 AC 71 ms
8,172 KB
testcase_21 AC 179 ms
13,648 KB
testcase_22 AC 102 ms
9,704 KB
testcase_23 AC 116 ms
10,292 KB
testcase_24 AC 993 ms
42,632 KB
testcase_25 AC 973 ms
42,552 KB
testcase_26 AC 998 ms
42,596 KB
testcase_27 AC 986 ms
42,500 KB
testcase_28 AC 1,023 ms
42,388 KB
testcase_29 AC 992 ms
42,504 KB
testcase_30 AC 994 ms
42,596 KB
testcase_31 AC 996 ms
42,556 KB
testcase_32 AC 969 ms
42,500 KB
testcase_33 AC 988 ms
42,428 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var pairs: []Pair :: #[n * (n - 1) / 2]Pair
	var x: []int :: #[n]int
	var y: []int :: #[n]int
	for i(0, n - 1)
		do x[i] :: cui@inputInt()
		do y[i] :: cui@inputInt()
	end for
	
	var idx: int :: 0
	for i(0, n - 1)
		for j(i + 1, n - 1)
			do pairs[idx] :: (#Pair).init(i, j, (x[i] - x[j]) ^ 2 + (y[i] - y[j]) ^ 2)
			do idx :+ 1
		end for
	end for
	do pairs.sort()
	
	var ans: int :: 0
	var used: []bool :: #[n]bool
	for i(0, idx - 1)
		var id1: int :: pairs[i].id1
		var id2: int :: pairs[i].id2
		if(id1 = 0)
			if(!used[id2])
				do used[id2] :: true
				do ans :+ 1
			end if
		else
			if(!used[id1] & !used[id2])
				do used[id1] :: true
				do used[id2] :: true
			end if
		end if
	end for
	do cui@print("\{ans}\n")
	
	class Pair()
		+var id1: int
		+var id2: int
		+var dist: int
		+func init(id1: int, id2: int, dist: int): Pair
			do me.id1 :: id1
			do me.id2 :: id2
			do me.dist :: dist
			ret me
		end func
		+*func cmp(t: kuin@Class): int
			ret me.dist - (t $ Pair).dist
		end func
	end class
end func
0