結果

問題 No.723 2つの数の和
ユーザー NacoNaco
提出日時 2019-09-20 14:42:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 170,932 KB
実行使用メモリ 11,764 KB
最終ジャッジ日時 2023-10-12 05:15:43
合計ジャッジ時間 3,980 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 55 ms
7,552 KB
testcase_04 AC 88 ms
9,876 KB
testcase_05 AC 81 ms
10,372 KB
testcase_06 AC 67 ms
8,232 KB
testcase_07 AC 29 ms
5,952 KB
testcase_08 AC 33 ms
6,432 KB
testcase_09 AC 66 ms
7,944 KB
testcase_10 AC 38 ms
6,852 KB
testcase_11 AC 7 ms
4,348 KB
testcase_12 AC 35 ms
6,476 KB
testcase_13 AC 97 ms
11,764 KB
testcase_14 AC 21 ms
5,948 KB
testcase_15 AC 38 ms
7,684 KB
testcase_16 AC 59 ms
9,552 KB
testcase_17 AC 78 ms
10,684 KB
testcase_18 AC 16 ms
4,348 KB
testcase_19 AC 30 ms
4,348 KB
testcase_20 AC 1 ms
4,352 KB
testcase_21 AC 1 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 70 ms
10,128 KB
testcase_24 AC 27 ms
6,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

static const int MAX=1e5+1;

int N;
int X;
int a[MAX];

int main(){
    cin >> N >> X;
    for(int i=0;i<N;i++) cin >> a[i];
    map<long long,long long> m;
    long long ans=0;
    for(int i=0;i<N;i++){
        m[a[i]]++;
    }
    for(int i=0;i<N;i++){
        if(X-a[i]>=0){
            ans+=m[X-a[i]];
        }
    }
    cout << ans << endl;
}
0