結果

問題 No.723 2つの数の和
ユーザー granddaifukugranddaifuku
提出日時 2020-07-18 14:19:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 175,108 KB
実行使用メモリ 9,416 KB
最終ジャッジ日時 2023-08-20 17:20:55
合計ジャッジ時間 3,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 42 ms
7,672 KB
testcase_04 AC 58 ms
8,236 KB
testcase_05 AC 50 ms
8,340 KB
testcase_06 AC 54 ms
8,136 KB
testcase_07 AC 23 ms
6,324 KB
testcase_08 AC 27 ms
6,436 KB
testcase_09 AC 57 ms
8,820 KB
testcase_10 AC 22 ms
5,968 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 32 ms
6,952 KB
testcase_13 AC 69 ms
9,416 KB
testcase_14 AC 14 ms
5,444 KB
testcase_15 AC 24 ms
6,520 KB
testcase_16 AC 36 ms
7,824 KB
testcase_17 AC 49 ms
8,636 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 38 ms
8,056 KB
testcase_24 AC 18 ms
5,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	map<int, int> mp;
	rep (i, n) {
	  cin >> a[i];
	  mp[a[i]]++;
	}
	ll res = 0;
	rep (i, n) {
	  res += mp[x - a[i]];
	}
	cout << res << endl;

	return 0;
}

0