結果

問題 No.723 2つの数の和
ユーザー MSKMSK
提出日時 2018-09-30 14:23:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 72,048 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 13:35:50
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 22 ms
5,376 KB
testcase_04 AC 28 ms
5,376 KB
testcase_05 AC 26 ms
5,376 KB
testcase_06 AC 29 ms
5,376 KB
testcase_07 AC 13 ms
5,376 KB
testcase_08 AC 15 ms
5,376 KB
testcase_09 AC 30 ms
5,376 KB
testcase_10 AC 14 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 29 ms
5,376 KB
testcase_24 AC 11 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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