結果

問題 No.723 2つの数の和
ユーザー NoiriNoiri
提出日時 2019-09-18 14:47:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 3,810 ms
コンパイル使用メモリ 172,832 KB
実行使用メモリ 9,760 KB
最終ジャッジ日時 2023-09-22 15:28:44
合計ジャッジ時間 4,091 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 51 ms
6,500 KB
testcase_04 AC 69 ms
7,428 KB
testcase_05 AC 62 ms
6,908 KB
testcase_06 AC 68 ms
7,008 KB
testcase_07 AC 27 ms
5,648 KB
testcase_08 AC 30 ms
5,648 KB
testcase_09 AC 72 ms
7,504 KB
testcase_10 AC 27 ms
5,308 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 34 ms
5,908 KB
testcase_13 AC 65 ms
7,284 KB
testcase_14 AC 16 ms
4,724 KB
testcase_15 AC 27 ms
5,452 KB
testcase_16 AC 40 ms
6,304 KB
testcase_17 AC 55 ms
6,812 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 30 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 86 ms
9,760 KB
testcase_24 AC 19 ms
4,924 KB
権限があれば一括ダウンロードができます

ソースコード

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