結果

問題 No.723 2つの数の和
コンテスト
ユーザー xxxasdfghjk
提出日時 2018-08-12 13:20:07
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 681 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 666 ms
コンパイル使用メモリ 107,312 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2026-04-11 14:02:04
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,X,res=0;
  cin >> N >> X;
  vector<ll> a(N+1);
  map<ll,ll> mp;
  REP(i,N){
    cin >> a[i];
    mp[a[i]]++;
    if(X - a[i] == a[i])
      res += mp[X-a[i]];
    else
      res += 2*mp[X-a[i]];
    
  }
  cout << res << endl;
  return 0;
}

0