結果

問題 No.723 2つの数の和
ユーザー totori_nyaa
提出日時 2019-07-17 20:47:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 402 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 1,847 ms
コンパイル使用メモリ 166,028 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 07:22:31
合計ジャッジ時間 4,021 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n,x;
    cin>>n>>x;
    ll a[111111]={};
    for(int i=0;i<n;i++){
        int b;
        cin>>b;
        a[b]++;
    }
    ll ans=0;
    for(int i=0;i<=x/2;i++){
        if(x-i>101010) continue;
        if(i==x/2 && i*2==x){
            ans+= a[i]*a[i];
        }
        else ans += 2*a[i]*a[x-i];
    }
    cout<<ans<<endl;

}
0