結果

問題 No.723 2つの数の和
ユーザー ei1333333
提出日時 2018-08-03 22:36:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 200,756 KB
最終ジャッジ日時 2025-01-06 12:13:21
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int main() {
  int N, X;
  cin >> N >> X;
  map< int, int > mp;
  int64 ret = 0, add = 0;
  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    ret += mp[X - A];
    mp[A]++;
    if(A + A == X) ++add;
  }
  cout << ret * 2 + add << endl;
}
0