結果

問題 No.723 2つの数の和
ユーザー fine
提出日時 2018-08-03 22:27:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 1,326 ms
コンパイル使用メモリ 168,852 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 17:28:59
合計ジャッジ時間 2,248 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<ll> cnt(100001, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    ll ans = 0;
    for (int i = 0; i <= 100000; i++) {
        int tar = x - i;
        if (tar < 0 || tar > 100000) continue;
        ans += cnt[i] * cnt[tar];
    }
    cout << ans << endl;
    return 0;
}
0