結果

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

ソースコード

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());
  int 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