結果

問題 No.723 2つの数の和
ユーザー NOSSNOSS
提出日時 2018-08-04 20:02:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 1,417 ms
コンパイル使用メモリ 168,408 KB
実行使用メモリ 11,512 KB
最終ジャッジ日時 2023-10-19 21:56:18
合計ジャッジ時間 3,572 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 58 ms
7,564 KB
testcase_04 AC 100 ms
9,840 KB
testcase_05 AC 94 ms
10,200 KB
testcase_06 AC 75 ms
8,160 KB
testcase_07 AC 30 ms
6,188 KB
testcase_08 AC 36 ms
6,568 KB
testcase_09 WA -
testcase_10 AC 35 ms
7,032 KB
testcase_11 AC 7 ms
4,384 KB
testcase_12 AC 39 ms
6,664 KB
testcase_13 AC 116 ms
11,512 KB
testcase_14 AC 26 ms
6,256 KB
testcase_15 AC 47 ms
7,880 KB
testcase_16 AC 72 ms
9,428 KB
testcase_17 AC 95 ms
10,644 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 74 ms
9,920 KB
testcase_24 AC 30 ms
6,684 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() {
    int n,x;
    map<int,ll> mp;
    cin >> n >> x;
    REP(i,n){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto itr : mp){
        if(itr.first > x)break;
        if(itr.first*2 == x)ans += itr.second*(itr.second+1)/2;
        else ans += itr.second*mp[x-itr.first];
    }
    cout << ans << endl;
    return 0;
}
0