結果

問題 No.723 2つの数の和
ユーザー kekenx
提出日時 2020-02-18 16:41:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 167,824 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 15:38:44
合計ジャッジ時間 2,913 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int cnt[100005];

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cnt[a[i]]++;


  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int d = x - a[i];
    if (d >= 0 && d <= 100000) ans += cnt[d];
  }
  cout << ans << endl;
  return 0;
}
0