結果

問題 No.723 2つの数の和
ユーザー tomatotomato
提出日時 2018-08-03 22:47:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 78,296 KB
実行使用メモリ 9,532 KB
最終ジャッジ日時 2023-10-19 21:32:34
合計ジャッジ時間 2,768 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 73 ms
7,808 KB
testcase_04 AC 98 ms
8,276 KB
testcase_05 AC 92 ms
8,544 KB
testcase_06 AC 96 ms
8,268 KB
testcase_07 AC 37 ms
6,524 KB
testcase_08 AC 43 ms
6,728 KB
testcase_09 AC 107 ms
8,972 KB
testcase_10 AC 34 ms
6,172 KB
testcase_11 AC 8 ms
4,364 KB
testcase_12 AC 51 ms
7,200 KB
testcase_13 AC 115 ms
9,532 KB
testcase_14 AC 22 ms
5,588 KB
testcase_15 AC 40 ms
6,808 KB
testcase_16 AC 64 ms
7,968 KB
testcase_17 AC 89 ms
8,880 KB
testcase_18 AC 17 ms
4,348 KB
testcase_19 AC 33 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 68 ms
8,336 KB
testcase_24 AC 27 ms
5,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  map<int, int> mp;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a * 2 == x) ans++;
    ans += mp[x - a] * 2;
    mp[a]++;
  }
  cout << ans << endl;
}
0