結果

問題 No.723 2つの数の和
ユーザー Noiri
提出日時 2019-09-18 14:47:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 174,696 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-07-08 07:04:08
合計ジャッジ時間 2,873 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n, x;
    cin >> n >> x;
    map<int, ll> m;
    rep(i, n){
        int a;
        cin >> a;
        m[a]++;
    }

    ll ans = 0;
    for(auto p: m){
        ll t = x - p.first;
        if(m.find(t) != m.end()) ans += p.second * m[t];
    }

    cout << ans << endl;
}
0