結果

問題 No.723 2つの数の和
ユーザー tanaka255
提出日時 2025-10-08 01:37:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 3,327 ms
コンパイル使用メモリ 274,860 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-08 01:37:56
合計ジャッジ時間 5,512 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int N, X, a[1 << 17], cnt[1 << 17];
long long ans = 0;
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> N >> X;
  rep(i, N) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  rep(i, N) {
    if (a[i] + a[i] == X)
      ++ans;
    else if (0 <= X - a[i] && X - a[i] < 1 << 17)
      ans += cnt[X - a[i]];
  }
  cout << ans << endl;
}
0