結果

問題 No.723 2つの数の和
ユーザー SSRS
提出日時 2020-11-12 15:41:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-07-22 19:12:55
合計ジャッジ時間 2,837 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
	int N, X;
	cin >> N >> X;
	vector<int> a(N);
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	map<int, int> mp;
	for (int i = 0; i < N; i++){
		mp[a[i]]++;
	}
	long long ans = 0;
	for (int i = 0; i < N; i++){
		ans += mp[X - a[i]];
	}
	cout << ans << endl;
}
0