結果

問題 No.723 2つの数の和
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-20 23:45:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 300 bytes
コンパイル時間 2,538 ms
コンパイル使用メモリ 201,572 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-04-16 04:29:07
合計ジャッジ時間 4,268 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 65 ms
7,808 KB
testcase_04 AC 88 ms
8,064 KB
testcase_05 AC 83 ms
8,448 KB
testcase_06 AC 92 ms
8,192 KB
testcase_07 AC 38 ms
6,528 KB
testcase_08 AC 45 ms
6,656 KB
testcase_09 AC 114 ms
8,832 KB
testcase_10 AC 34 ms
6,272 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 50 ms
7,040 KB
testcase_13 AC 111 ms
9,344 KB
testcase_14 AC 21 ms
5,504 KB
testcase_15 AC 41 ms
6,784 KB
testcase_16 AC 60 ms
7,808 KB
testcase_17 AC 86 ms
8,704 KB
testcase_18 AC 17 ms
5,376 KB
testcase_19 AC 34 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 67 ms
8,192 KB
testcase_24 AC 28 ms
5,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n,x;cin>>n>>x;
    map<int,int> mp;
    ll ans=0;
    for (int i=0;i<n;i++) {
        int a;cin>>a;
        mp[a]++;
        ans+=2*mp[x-a];
        if (a==x-a) ans--;
    }
    cout<<ans<<endl;
    return 0;
}
0