結果

問題 No.723 2つの数の和
ユーザー ldsyb
提出日時 2018-11-07 18:30:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 171,908 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-20 20:49:48
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t n, x;
	cin >> n >> x;
	vector<int64_t> as(n);
	for (auto &a : as)
	{
		cin >> a;
	}
	sort(as.begin(), as.end());
	int64_t ans = 0;
	for (auto &a : as)
	{
		int64_t b = x - a;
		ans += distance(lower_bound(as.begin(), as.end(), b), upper_bound(as.begin(), as.end(), b));
	}
	cout << ans << endl;
	return 0;
}
0