結果

問題 No.723 2つの数の和
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-08 23:09:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 205,728 KB
実行使用メモリ 9,700 KB
最終ジャッジ日時 2023-08-27 06:48:45
合計ジャッジ時間 4,490 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 50 ms
7,852 KB
testcase_04 AC 69 ms
8,444 KB
testcase_05 AC 62 ms
8,608 KB
testcase_06 AC 64 ms
8,452 KB
testcase_07 AC 28 ms
6,432 KB
testcase_08 AC 30 ms
6,656 KB
testcase_09 AC 71 ms
9,180 KB
testcase_10 AC 26 ms
6,052 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 37 ms
7,088 KB
testcase_13 AC 74 ms
9,700 KB
testcase_14 AC 16 ms
5,364 KB
testcase_15 AC 29 ms
6,812 KB
testcase_16 AC 44 ms
7,976 KB
testcase_17 AC 60 ms
8,884 KB
testcase_18 AC 8 ms
4,380 KB
testcase_19 AC 11 ms
4,384 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 44 ms
8,616 KB
testcase_24 AC 20 ms
5,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int n, x, a[100000];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n >> x;
  rep(i, n) cin >> a[i];
  map<int, int> cnt;
  rep(i, n) {
    cnt[x-a[i]]++;
  }
  ll ans = 0;
  rep(i, n) {
    ans += cnt[a[i]];
  }
  cout << ans << '\n';
  return 0;
}
0