結果

問題 No.723 2つの数の和
ユーザー ldsybldsyb
提出日時 2018-11-07 18:27:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 172,460 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-30 22:30:58
合計ジャッジ時間 3,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 32 ms
6,940 KB
testcase_04 AC 42 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 39 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 20 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 18 ms
6,940 KB
testcase_11 AC 5 ms
6,944 KB
testcase_12 AC 22 ms
6,940 KB
testcase_13 AC 41 ms
6,940 KB
testcase_14 AC 11 ms
6,944 KB
testcase_15 AC 18 ms
6,940 KB
testcase_16 AC 26 ms
6,940 KB
testcase_17 AC 34 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 45 ms
6,944 KB
testcase_24 AC 13 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int64_t n, x;
    cin >> n >> x;
    vector<int64_t> as(n);
    for(auto&a:as){
        cin>>a;
    }
    sort(as.begin(),as.end());
    int64_t ans = 0;
    for(auto&a:as){
        int64_t b=x-a;
        ans+=distance(lower_bound(as.begin(),as.end(),b),upper_bound(as.begin(),as.end(),b))-(a==b);
    }
    cout<<ans<<endl;
    return 0;
}
0