結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2018-12-31 00:06:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 935 ms / 2,000 ms |
コード長 | 711 bytes |
コンパイル時間 | 131 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 20,932 KB |
最終ジャッジ日時 | 2024-10-09 11:03:44 |
合計ジャッジ時間 | 12,653 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
# -*- coding: utf-8 -*- n,x = map(int, input().split()) al = [int(x) for x in input().split()] al.sort() def lower_bound(al, key): def isOk(a): return a>=key ng = -1 ok = len(al) while abs(ok-ng)>1: mid = (ok+ng)//2 if isOk(al[mid]): ok = mid else: ng = mid return ok def upper_bound(al, key): def isOk(a): return a>key ng = -1 ok = len(al) while abs(ok-ng)>1: mid = (ok+ng)//2 if isOk(al[mid]): ok = mid else: ng = mid return ok cnt = 0 for a in al: l = lower_bound(al, x-a) u = upper_bound(al, x-a) if u>l>=0: cnt += u-l print(cnt)