結果

問題 No.723 2つの数の和
ユーザー MSK
提出日時 2018-09-30 14:23:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 71,552 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 09:06:02
合計ジャッジ時間 2,006 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N, X;
  cin >> N >> X;
  if(X > 200000){
    cout << 0 << endl;
    return 0;
  }
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];

  }
  vector<int> S(200001, 0);
  for(int i = 0; i < N; S[a[i]]++, i++) {}
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(a[i] > X){
      continue;

    }
    if(a[i] == X - a[i]){
      ans += S[a[i]] * S[a[i]];
      S[a[i]] = 0;

    }else{
      ans += 2 * S[a[i]] * S[X-a[i]];
      S[a[i]] = 0;
      S[X - a[i]] = 0;

    }
  }
  cout << ans << endl;
  return 0;

}
0