結果

問題 No.723 2つの数の和
ユーザー ajiruajiru
提出日時 2020-02-09 07:28:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 68,736 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-01 05:45:27
合計ジャッジ時間 1,934 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n, x;
	cin >> n >> x;
	vector<int> A(n), cnt(100100, 0);
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < n; ++i) ++cnt[A[i]];
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		int diff = x - A[i];
		if (0 <= diff && diff <= 100000)
			ans += cnt[diff];
	}
	cout << ans << endl;
	return 0;
}
0