結果

問題 No.723 2つの数の和
ユーザー ldsybldsyb
提出日時 2018-11-07 18:27:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 404 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 170,556 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-13 04:08:02
合計ジャッジ時間 3,775 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 29 ms
4,384 KB
testcase_04 AC 40 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 37 ms
4,384 KB
testcase_07 WA -
testcase_08 AC 18 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 17 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 21 ms
4,380 KB
testcase_13 AC 39 ms
4,384 KB
testcase_14 AC 10 ms
4,384 KB
testcase_15 AC 17 ms
4,380 KB
testcase_16 AC 24 ms
4,380 KB
testcase_17 AC 31 ms
4,384 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 41 ms
4,380 KB
testcase_24 AC 12 ms
4,384 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