結果

問題 No.723 2つの数の和
コンテスト
ユーザー Unbakedbread
提出日時 2025-11-03 16:18:05
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 3,182 ms
コンパイル使用メモリ 281,504 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-11-03 16:18:11
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge4 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

int main(void) {
	int N, X;
	cin >> N >> X;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) cin >> a[i];
	
	sort(a.begin(), a.end());
	ll ans = 0;
	for(auto x : a) ans += (upper_bound(a.begin(), a.end(), X - x) - lower_bound(a.begin(), a.end(), X - x));
	cout << ans << endl;
	return 0;
}
0