結果

問題 No.723 2つの数の和
ユーザー kekenx
提出日時 2020-02-18 16:28:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 1,792 ms
コンパイル使用メモリ 177,296 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-10-06 15:37:49
合計ジャッジ時間 3,810 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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