結果

問題 No.723 2つの数の和
ユーザー kyo1kyo1
提出日時 2020-07-05 15:58:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 205,876 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-23 19:33:30
合計ジャッジ時間 4,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 13 ms
4,348 KB
testcase_04 AC 17 ms
4,348 KB
testcase_05 AC 16 ms
4,348 KB
testcase_06 AC 16 ms
4,348 KB
testcase_07 AC 8 ms
4,348 KB
testcase_08 AC 9 ms
4,348 KB
testcase_09 AC 17 ms
4,348 KB
testcase_10 AC 8 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 18 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 8 ms
4,348 KB
testcase_16 AC 12 ms
4,348 KB
testcase_17 AC 15 ms
4,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 13 ms
4,348 KB
testcase_24 AC 7 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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