結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 58 ms
7,296 KB
testcase_04 AC 99 ms
9,728 KB
testcase_05 AC 101 ms
9,984 KB
testcase_06 AC 75 ms
8,064 KB
testcase_07 AC 31 ms
6,016 KB
testcase_08 AC 36 ms
6,400 KB
testcase_09 AC 75 ms
7,808 KB
testcase_10 AC 38 ms
6,784 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 40 ms
6,528 KB
testcase_13 AC 122 ms
11,520 KB
testcase_14 AC 30 ms
6,016 KB
testcase_15 AC 53 ms
7,808 KB
testcase_16 AC 78 ms
9,216 KB
testcase_17 AC 103 ms
10,624 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 87 ms
9,728 KB
testcase_24 AC 34 ms
6,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
  int n;
  ll 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