結果

問題 No.723 2つの数の和
ユーザー とばり
提出日時 2018-09-03 21:04:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 178,272 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-10-09 09:53:47
合計ジャッジ時間 3,518 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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