結果

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X;
  cin >> N >> X;
  vector<int> A(N), B(100010, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[A[i]]++;
  }
  sort(A.begin(), A.end());
  int64_t res = 0;
  for (int i = 0; i < N; i++) {
    int x = X - A[i];
    if (x >= 0 && x < (int)B.size()) res += B[x];
  }
  cout << res << '\n';
  return 0;
}
0