結果

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

ソースコード

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];
long long ans = 0, cnt[1 << 17];
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> N >> X;
  rep(i, N) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  rep(i, N) {
    int tgt = X - a[i];
    if (0 <= tgt && tgt < 1 << 17) ans += cnt[tgt];
  }
  cout << ans << endl;
}
0