結果

問題 No.723 2つの数の和
ユーザー とばりとばり
提出日時 2018-09-03 21:04:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 172,272 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-04-17 15:49:43
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 48 ms
6,912 KB
testcase_04 AC 65 ms
7,680 KB
testcase_05 AC 55 ms
7,296 KB
testcase_06 AC 61 ms
7,552 KB
testcase_07 AC 26 ms
5,568 KB
testcase_08 AC 30 ms
5,760 KB
testcase_09 AC 63 ms
7,808 KB
testcase_10 AC 27 ms
5,460 KB
testcase_11 AC 6 ms
5,376 KB
testcase_12 AC 33 ms
6,184 KB
testcase_13 AC 61 ms
7,936 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 25 ms
5,640 KB
testcase_16 AC 39 ms
6,536 KB
testcase_17 AC 50 ms
7,424 KB
testcase_18 AC 16 ms
5,376 KB
testcase_19 AC 32 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 98 ms
10,112 KB
testcase_24 AC 19 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using int64 = long long;
using uint64 = unsigned long long;

int main()
{
    int N;
    int64 X;
    cin >> N >> X;

    map<int, int64> counter;
    vector<int64> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        counter[a[i]]++;
    }

    int64 ans = 0;
    for (auto mp : counter)
    {
        if (counter.count(X - mp.first) == 0) continue;
        ans += counter[mp.first] * counter[X - mp.first];
    }

    cout << ans << endl;

    return 0;
}
0