結果

問題 No.723 2つの数の和
ユーザー misora192
提出日時 2020-05-15 08:11:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,766 ms
コンパイル使用メモリ 178,432 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-09-17 11:56:12
合計ジャッジ時間 4,027 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	ll x;
	cin >> n >> x;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	map<ll, int> mp;
	rep(i, n){
		if(mp.count(a[i]) == 0) mp[a[i]] = 0;
		mp[a[i]]++;
	}

	ll ans = 0;
	rep(i, n){
		if(mp.count(x - a[i]) > 0){
			ans += mp[x - a[i]];
		}
	}

	cout << ans << endl;	
}
0