結果

問題 No.723 2つの数の和
ユーザー sawfish
提出日時 2022-10-24 00:53:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 525 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 69,504 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-02 12:43:09
合計ジャッジ時間 4,815 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int N, X;
    cin >> N >> X;

    int a[N];
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a, a + N);

    LL ans = 0;
    for (int i = 0; i < N; i++) {
        int *p = lower_bound(a, a + N, X - a[i]);
        int *q = upper_bound(a, a + N, X - a[i]);
        for (int j = p - a; j < q - a; j++) {
            if (a[i] + a[j] == X) ans++;
        }
    }

    cout << ans << endl;
}
0