結果

問題 No.723 2つの数の和
ユーザー bellangeldindonbellangeldindon
提出日時 2019-05-17 09:39:48
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 605 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 7,108 KB
実行使用メモリ 15,088 KB
最終ジャッジ日時 2023-10-17 07:13:22
合計ジャッジ時間 6,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,448 KB
testcase_01 AC 11 ms
6,448 KB
testcase_02 AC 11 ms
6,448 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 370 ms
15,040 KB
testcase_14 AC 112 ms
8,408 KB
testcase_15 AC 185 ms
9,920 KB
testcase_16 AC 258 ms
11,776 KB
testcase_17 AC 319 ms
13,460 KB
testcase_18 AC 70 ms
10,248 KB
testcase_19 AC 82 ms
15,088 KB
testcase_20 AC 11 ms
6,448 KB
testcase_21 AC 11 ms
6,448 KB
testcase_22 AC 11 ms
6,448 KB
testcase_23 AC 524 ms
15,084 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def binarysrch(lst, lft, rgt, trg):
	if lft == rgt:
		if lst[lft] == trg: return lft
		return -1
	m = (lft+rgt)/2
	if trg <= lst[m]: return binarysrch(lst, lft, m, trg)
	return binarysrch(lst, m+1, rgt, trg)

N, X = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
number = []
count = []
tmp = -1
for i in range(0, N):
	if a[i] != tmp:
		number.append(a[i])
		count.append(1)
		tmp = a[i]
	else: count[-1] += 1
ans = 0
for i in range(0, len(number)):
	target = X - a[i]
	judge = binarysrch(number, 0, len(number)-1, target)
	if judge != -1:
		ans += count[i]*count[judge]
print ans
0