結果

問題 No.723 2つの数の和
ユーザー m-44m-44
提出日時 2019-09-18 23:52:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 172,076 KB
実行使用メモリ 9,648 KB
最終ジャッジ日時 2023-09-24 23:12:14
合計ジャッジ時間 4,256 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 52 ms
6,500 KB
testcase_04 AC 68 ms
7,272 KB
testcase_05 AC 58 ms
6,920 KB
testcase_06 AC 73 ms
7,080 KB
testcase_07 AC 29 ms
5,376 KB
testcase_08 AC 32 ms
5,864 KB
testcase_09 AC 75 ms
7,492 KB
testcase_10 AC 27 ms
5,460 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 39 ms
5,868 KB
testcase_13 AC 76 ms
7,276 KB
testcase_14 AC 16 ms
4,644 KB
testcase_15 AC 29 ms
5,508 KB
testcase_16 AC 45 ms
6,288 KB
testcase_17 AC 64 ms
7,036 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 30 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 74 ms
9,648 KB
testcase_24 AC 19 ms
4,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, x;
  cin>>n>>x;

  map<int, long> m;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    ++m[a];
  }
  long long ans = 0;
  for (auto e: m) {
    int a = e.first;
    long cnt = e.second;
    auto it = m.lower_bound(x - a);
    if (it == m.end()) {
      continue;
    } else if ((*it).first == x - a) {
      ans += cnt * (*it).second;
    }
  }
  cout<<ans<<endl;
}
0