結果

問題 No.723 2つの数の和
ユーザー kusshikusshi
提出日時 2019-11-16 16:29:46
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 488 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 164,444 KB
実行使用メモリ 814,288 KB
最終ジャッジ日時 2023-10-25 04:20:20
合計ジャッジ時間 4,478 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 26 ms
4,348 KB
testcase_04 AC 35 ms
4,348 KB
testcase_05 AC 32 ms
4,348 KB
testcase_06 AC 32 ms
4,348 KB
testcase_07 AC 16 ms
4,348 KB
testcase_08 AC 17 ms
4,348 KB
testcase_09 AC 35 ms
4,348 KB
testcase_10 AC 15 ms
4,348 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 20 ms
4,348 KB
testcase_13 RE -
testcase_14 MLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, x;
    ll ans = 0;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n)    cin >> a.at(i);
    sort(a.begin(), a.end());

    vector<int> b(x+1);
    for(int i = 0; i < n && a.at(i) < x+1; ++i){
        ++b.at(a.at(i));
    }

    for(int i = 0; i <= x; ++i){
        ans += b.at(i) * b.at(x-i);
    }

    cout << ans << endl;
    
    return 0;
}
0