結果

問題 No.723 2つの数の和
ユーザー bellangeldindon
提出日時 2019-05-20 10:57:21
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 15,524 KB
最終ジャッジ日時 2024-09-17 06:38:37
合計ジャッジ時間 2,603 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 9 WA * 12 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def binarysrch(lst, n, left, right):
	if left < right: return -1
	md = (left+right)/2
	if lst[md] > n: return binarysrch(lst, n, left, md-1)
	if lst[md] < n: return binarysrch(lst, n, md+1, right)
	return md

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: count[-1] += 1
	else:
		number.append(a[i])
		count.append(1)
		tmp = a[i]
sum = 0
for i in range(0, len(number)):
	srch = binarysrch(number, X-a[i], 0, len(number)-1)
	if srch != -1:
		sum += count[i]*count[srch]
print sum
0