結果

問題 No.723 2つの数の和
ユーザー heabiheabi
提出日時 2020-12-21 00:57:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 2,010 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 173,816 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 11:24:49
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 17 ms
4,348 KB
testcase_04 AC 24 ms
4,348 KB
testcase_05 AC 20 ms
4,348 KB
testcase_06 AC 22 ms
4,348 KB
testcase_07 AC 10 ms
4,348 KB
testcase_08 AC 11 ms
4,348 KB
testcase_09 AC 21 ms
4,348 KB
testcase_10 AC 11 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 12 ms
4,348 KB
testcase_13 AC 21 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 9 ms
4,348 KB
testcase_16 AC 14 ms
4,348 KB
testcase_17 AC 18 ms
4,348 KB
testcase_18 AC 12 ms
4,348 KB
testcase_19 AC 16 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 24 ms
4,348 KB
testcase_24 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep_up(i, a, b) for (ll i = a; i < b; ++i)
#define rep_down(i, a, b) for (ll i = a; i > b; --i)

#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second

#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>

#define vvvvdo vector<vector<vector<vector<double>>>>
#define vvvdo vector<vector<vector<double>>>
#define vvdo vector<vector<double>>
#define vdo vector<double>

#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
// constexpr ll mod = 998244353;
constexpr ll mod = 1000000007;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

void pt_vvll(vvll v) {
    ll vs = v.size(), vs0 = v[0].size();
    rep(i, vs) {
        rep(j, vs0) {
            if (v[i][j] != INF)
                cout << v[i][j];
            else
                cout << -1;

            if (j != vs0 - 1)
                cout << " ";
            else
                cout << "\n";
        }
    }
}
void pt_vll(vll v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];
        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}

bool debug_flg = 0;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N, X;
    cin >> N >> X;
    vll a(N);
    rep(i, N) cin >> a[i];

    sort(a.begin(), a.end());
    ll ans = 0;
    rep(i, N) {
        ans += upper_bound(a.begin(), a.end(), X - a[i]) -
               lower_bound(a.begin(), a.end(), X - a[i]);
    }
    cout << ans << "\n";
    return 0;
}
0