結果

問題 No.723 2つの数の和
ユーザー mikianaaamikianaaa
提出日時 2020-10-17 20:36:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 172,348 KB
実行使用メモリ 11,712 KB
最終ジャッジ日時 2023-09-28 08:34:27
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 55 ms
9,064 KB
testcase_04 AC 73 ms
9,824 KB
testcase_05 AC 67 ms
10,204 KB
testcase_06 AC 70 ms
9,852 KB
testcase_07 AC 30 ms
7,372 KB
testcase_08 AC 34 ms
7,488 KB
testcase_09 AC 75 ms
10,916 KB
testcase_10 AC 28 ms
6,676 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 40 ms
8,120 KB
testcase_13 AC 76 ms
11,712 KB
testcase_14 AC 17 ms
5,948 KB
testcase_15 AC 31 ms
7,524 KB
testcase_16 AC 47 ms
9,328 KB
testcase_17 AC 63 ms
10,660 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 12 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 54 ms
10,068 KB
testcase_24 AC 21 ms
6,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, X;
    cin >> N >> X;
    vector<ll> A(N);
    map<ll, ll> ma;
    rep(i, N) {
        cin >> A[i];
        ma[A[i]]++;
    }

    ll ans = 0;
    rep(i, N) {
        ll a = X - A[i];
        ans += ma[a];
    }

    cout << ans << endl;
}
0