結果

問題 No.723 2つの数の和
ユーザー phsplsphspls
提出日時 2020-04-19 15:32:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 581 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 177,652 KB
実行使用メモリ 12,784 KB
最終ジャッジ日時 2023-07-28 04:49:42
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,500 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 88 ms
8,000 KB
testcase_04 AC 126 ms
9,264 KB
testcase_05 AC 105 ms
8,716 KB
testcase_06 AC 117 ms
8,900 KB
testcase_07 AC 43 ms
6,308 KB
testcase_08 AC 51 ms
6,664 KB
testcase_09 AC 118 ms
9,184 KB
testcase_10 AC 43 ms
6,352 KB
testcase_11 AC 8 ms
4,380 KB
testcase_12 AC 58 ms
7,192 KB
testcase_13 AC 123 ms
9,288 KB
testcase_14 AC 23 ms
5,300 KB
testcase_15 AC 43 ms
6,616 KB
testcase_16 AC 73 ms
7,716 KB
testcase_17 AC 101 ms
8,512 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 31 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 142 ms
12,784 KB
testcase_24 AC 30 ms
5,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long

int main() {
    int n, x;
    cin >> n >> x;
    map<int, int> a;
    set<int> keys;
    rep(i, n) {
        int val;
        cin >> val;
        if(a.count(val)) a[val]++;
        else a[val] = 1;
        keys.insert(val);
    }

    llong result = 0LL;
    for(pair<int, int> p: a) {
        if(p.first > x) break;
        if(a.count(x - p.first)) {
            result += (llong)a[p.first] * a[x - p.first];
        }
    }

    cout << result << "\n";
}
0