結果

問題 No.723 2つの数の和
ユーザー tokizotokizo
提出日時 2019-03-09 10:37:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 175,332 KB
実行使用メモリ 9,340 KB
最終ジャッジ日時 2023-09-05 19:48:25
合計ジャッジ時間 3,468 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 46 ms
7,612 KB
testcase_04 AC 62 ms
7,988 KB
testcase_05 AC 57 ms
8,360 KB
testcase_06 AC 57 ms
8,044 KB
testcase_07 AC 26 ms
6,516 KB
testcase_08 AC 28 ms
6,456 KB
testcase_09 AC 63 ms
8,884 KB
testcase_10 AC 24 ms
6,024 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 33 ms
6,876 KB
testcase_13 AC 67 ms
9,340 KB
testcase_14 AC 16 ms
5,160 KB
testcase_15 AC 28 ms
6,540 KB
testcase_16 AC 43 ms
7,708 KB
testcase_17 AC 59 ms
8,648 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 47 ms
8,136 KB
testcase_24 AC 20 ms
5,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, x;
    cin >> n >> x;
    vector<int> A(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        mp[A[i]]++;
    }
    if(x == 0){
        cout << (long long)n * (long long)n << endl;
        return 0;
    }

    sort(A.begin(), A.end());

    int ans = 0;
    for(int i = 0; i < n; i++){
        int r = x - A[i];
        ans += mp[r];
    }

    cout << ans << endl;

    return 0;
}
0