結果

問題 No.723 2つの数の和
ユーザー tomato
提出日時 2018-08-03 22:47:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 78,312 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-09-19 17:33:40
合計ジャッジ時間 2,260 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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