結果

問題 No.723 2つの数の和
ユーザー NacoNaco
提出日時 2019-09-20 14:39:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 405 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 173,504 KB
実行使用メモリ 11,568 KB
最終ジャッジ日時 2023-10-12 05:12:59
合計ジャッジ時間 3,823 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 47 ms
7,448 KB
testcase_04 AC 75 ms
10,072 KB
testcase_05 AC 71 ms
10,276 KB
testcase_06 AC 60 ms
8,092 KB
testcase_07 AC 26 ms
6,000 KB
testcase_08 AC 30 ms
6,528 KB
testcase_09 AC 59 ms
8,016 KB
testcase_10 AC 31 ms
6,772 KB
testcase_11 AC 7 ms
4,352 KB
testcase_12 AC 34 ms
6,544 KB
testcase_13 AC 85 ms
11,568 KB
testcase_14 AC 21 ms
6,004 KB
testcase_15 AC 35 ms
7,804 KB
testcase_16 AC 53 ms
9,324 KB
testcase_17 AC 70 ms
10,652 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 73 ms
10,060 KB
testcase_24 AC 24 ms
6,460 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];
    sort(a,a+N);
    map<long long,long long> m;
    int 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