結果

問題 No.723 2つの数の和
ユーザー Yut176Yut176
提出日時 2019-05-26 23:49:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 834 ms
コンパイル使用メモリ 94,460 KB
実行使用メモリ 8,356 KB
最終ジャッジ日時 2023-10-17 18:06:01
合計ジャッジ時間 2,744 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 48 ms
6,032 KB
testcase_04 AC 67 ms
6,512 KB
testcase_05 AC 58 ms
6,352 KB
testcase_06 AC 64 ms
6,492 KB
testcase_07 AC 26 ms
5,196 KB
testcase_08 AC 30 ms
5,348 KB
testcase_09 AC 65 ms
6,560 KB
testcase_10 AC 26 ms
5,120 KB
testcase_11 AC 6 ms
4,348 KB
testcase_12 AC 34 ms
5,560 KB
testcase_13 AC 68 ms
6,756 KB
testcase_14 AC 15 ms
4,732 KB
testcase_15 AC 27 ms
5,248 KB
testcase_16 AC 41 ms
5,828 KB
testcase_17 AC 56 ms
6,284 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 73 ms
8,356 KB
testcase_24 AC 19 ms
4,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9 + 7;

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

  int cnt = 0;
  for(auto i=m.begin(); i!=m.end(); i++) {
    if(i->first*2 == x) {
      cnt += i->second * (i->second);
    }else{
      if(m.find(x - i->first) == m.end()) continue;
      cnt += i->second * m[x - i->first];
    }
  }
  cout << cnt << endl;
  

  return 0;
}



// EOF
0