結果

問題 No.723 2つの数の和
ユーザー xxxasdfghjkxxxasdfghjk
提出日時 2018-08-12 13:20:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 82,616 KB
実行使用メモリ 11,888 KB
最終ジャッジ日時 2023-10-24 16:09:29
合計ジャッジ時間 2,910 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 64 ms
9,248 KB
testcase_04 AC 83 ms
10,040 KB
testcase_05 AC 79 ms
10,304 KB
testcase_06 AC 82 ms
10,040 KB
testcase_07 AC 36 ms
7,472 KB
testcase_08 AC 40 ms
7,740 KB
testcase_09 WA -
testcase_10 AC 33 ms
7,000 KB
testcase_11 AC 8 ms
4,652 KB
testcase_12 AC 47 ms
8,368 KB
testcase_13 AC 94 ms
11,888 KB
testcase_14 AC 21 ms
6,224 KB
testcase_15 AC 38 ms
7,848 KB
testcase_16 AC 58 ms
9,512 KB
testcase_17 AC 78 ms
10,832 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 72 ms
10,304 KB
testcase_24 AC 26 ms
6,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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