結果

問題 No.723 2つの数の和
ユーザー どららどらら
提出日時 2018-08-04 11:50:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 173,796 KB
実行使用メモリ 9,536 KB
最終ジャッジ日時 2023-10-19 21:47:37
合計ジャッジ時間 3,851 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 57 ms
6,572 KB
testcase_04 AC 101 ms
8,280 KB
testcase_05 AC 98 ms
8,548 KB
testcase_06 AC 80 ms
7,024 KB
testcase_07 AC 30 ms
5,540 KB
testcase_08 AC 36 ms
5,828 KB
testcase_09 AC 80 ms
6,828 KB
testcase_10 AC 39 ms
6,176 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 41 ms
5,900 KB
testcase_13 AC 123 ms
9,536 KB
testcase_14 AC 28 ms
5,592 KB
testcase_15 AC 51 ms
6,812 KB
testcase_16 AC 76 ms
7,972 KB
testcase_17 AC 101 ms
8,884 KB
testcase_18 AC 18 ms
4,348 KB
testcase_19 AC 34 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 82 ms
8,340 KB
testcase_24 AC 33 ms
5,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, X;
  cin >> N >> X;
  map<int,int> A;
  rep(i,N){
    int a;
    cin >> a;
    A[a]++;
  }

  ll ret = 0;
  FOR(it,A){
    int ai = it->first;
    int aj = X - ai;
    if(aj < 0) continue;
    ret += A[ai] * (ll)A[aj];
  }

  cout << ret << endl;
  
  return 0;
}

0