結果

問題 No.723 2つの数の和
ユーザー ikd
提出日時 2017-08-07 16:07:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 59,136 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 22:28:27
合計ジャッジ時間 1,725 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)

int main(){

   int N, X;
   cin>> N>> X;
   int a[N];
   repeat(i, N) cin>> a[i];

   vector<int> cnt(100005, 0);
   for(int e: a) cnt[e]++;
   long long ans=0;
   for(int e: a){
      if(X-e<0 or X-e>=cnt.size()) continue;
      ans+=cnt[X-e];
   }

   cout<< ans<< endl;

   return 0;
}
0