結果

問題 No.723 2つの数の和
ユーザー NOSSNOSS
提出日時 2018-08-04 20:11:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 945 bytes
コンパイル時間 1,351 ms
コンパイル使用メモリ 166,704 KB
実行使用メモリ 11,516 KB
最終ジャッジ日時 2023-10-19 21:56:46
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 56 ms
7,568 KB
testcase_04 AC 88 ms
9,844 KB
testcase_05 AC 86 ms
10,204 KB
testcase_06 AC 71 ms
8,164 KB
testcase_07 AC 29 ms
6,192 KB
testcase_08 AC 33 ms
6,572 KB
testcase_09 AC 69 ms
7,908 KB
testcase_10 AC 35 ms
7,036 KB
testcase_11 AC 8 ms
4,388 KB
testcase_12 AC 38 ms
6,668 KB
testcase_13 AC 108 ms
11,516 KB
testcase_14 AC 25 ms
6,260 KB
testcase_15 AC 45 ms
7,884 KB
testcase_16 AC 68 ms
9,432 KB
testcase_17 AC 90 ms
10,648 KB
testcase_18 AC 17 ms
4,348 KB
testcase_19 AC 32 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 73 ms
9,924 KB
testcase_24 AC 29 ms
6,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(2e3) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)


int main() {
    ll n,x;
    map<ll,ll> mp;
    cin >> n >> x;
    REP(i,n){
        int a;
        cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for(auto itr : mp){
        if(itr.first > x)break;
        if(itr.first*2 == x)ans += itr.second*itr.second;
        else ans += itr.second*mp[x-itr.first];
    }
    cout << ans << endl;
    return 0;
}
0