結果

問題 No.723 2つの数の和
ユーザー Mayimg
提出日時 2019-04-15 20:26:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 201,764 KB
最終ジャッジ日時 2025-01-07 02:14:39
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, x;
  cin >> n >> x;
  map<int, int> mp;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int in;
    cin >> in;
    mp[in]++;
    if (!mp.count(x - in)) continue;
    ans += mp[x - in] * 2 + (in + in == x ? -1 : 0);
  }
  cout << ans << endl;
  return 0;
}
0