結果

問題 No.723 2つの数の和
ユーザー bellangeldindonbellangeldindon
提出日時 2019-05-20 10:53:03
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 7,120 KB
実行使用メモリ 15,492 KB
最終ジャッジ日時 2023-10-17 08:04:59
合計ジャッジ時間 6,450 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,424 KB
testcase_01 AC 10 ms
6,424 KB
testcase_02 AC 10 ms
6,424 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 389 ms
15,012 KB
testcase_14 AC 111 ms
8,484 KB
testcase_15 AC 184 ms
9,896 KB
testcase_16 AC 260 ms
11,752 KB
testcase_17 AC 331 ms
13,436 KB
testcase_18 AC 67 ms
10,224 KB
testcase_19 AC 77 ms
15,064 KB
testcase_20 AC 11 ms
6,424 KB
testcase_21 AC 10 ms
6,424 KB
testcase_22 AC 10 ms
6,424 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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