結果

問題 No.723 2つの数の和
ユーザー kekenxkekenx
提出日時 2020-02-18 16:28:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 171,264 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-16 04:10:52
合計ジャッジ時間 3,683 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 58 ms
7,424 KB
testcase_04 AC 93 ms
9,600 KB
testcase_05 AC 96 ms
9,984 KB
testcase_06 AC 75 ms
7,936 KB
testcase_07 AC 30 ms
6,948 KB
testcase_08 AC 36 ms
6,944 KB
testcase_09 AC 76 ms
7,680 KB
testcase_10 AC 37 ms
6,944 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 40 ms
6,944 KB
testcase_13 AC 121 ms
11,392 KB
testcase_14 AC 29 ms
6,944 KB
testcase_15 AC 52 ms
7,680 KB
testcase_16 AC 78 ms
9,344 KB
testcase_17 AC 101 ms
10,624 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 87 ms
9,856 KB
testcase_24 AC 34 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  int n, x;
  cin >> n >> x;
  map<ll, int> m;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    m[a]++;
  }

  ll ans = 0;
  for (auto e: m) {
    if (e.first > x) continue;
    if (x - e.first == e.first) {
      ans += m[e.first] * m[e.first];
    } else {
      ans += m[e.first] * m[x - e.first];
    }
  }
  cout << ans << endl;
  return 0;
}
0