結果

問題 No.723 2つの数の和
ユーザー MayimgMayimg
提出日時 2019-04-15 20:26:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 210,244 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-10-22 06:46:31
合計ジャッジ時間 4,398 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 35 ms
6,012 KB
testcase_04 AC 51 ms
6,492 KB
testcase_05 AC 40 ms
6,332 KB
testcase_06 AC 47 ms
6,408 KB
testcase_07 AC 19 ms
5,176 KB
testcase_08 AC 22 ms
5,328 KB
testcase_09 AC 46 ms
6,540 KB
testcase_10 AC 20 ms
5,100 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 24 ms
5,540 KB
testcase_13 AC 42 ms
6,528 KB
testcase_14 AC 10 ms
4,604 KB
testcase_15 AC 18 ms
5,164 KB
testcase_16 AC 26 ms
5,744 KB
testcase_17 AC 35 ms
6,200 KB
testcase_18 AC 8 ms
4,348 KB
testcase_19 AC 12 ms
4,348 KB
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 51 ms
8,336 KB
testcase_24 AC 13 ms
4,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, x;
  cin >> n >> x;
  map<int, int> mp;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int in;
    cin >> in;
    mp[in]++;
    if (!mp.count(x - in)) continue;
    ans += mp[x - in] * 2 + (in + in == x ? -1 : 0);
  }
  cout << ans << endl;
  return 0;
}
0