結果

問題 No.723 2つの数の和
ユーザー kyabaria
提出日時 2018-09-09 13:27:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 1,142 ms
コンパイル使用メモリ 159,324 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 06:43:25
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef unsigned long long ll;
#define INF 1000000000
using namespace std;
#define N 100000
int main(void){
    int n,x;
    cin>>n>>x;
    int cnt[N+5]={0};
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    
    ll ans=0;
    for(int i=0;i<n;i++){
        int d=x-a[i];
        if(0<=d and d<=N){
            ans+=cnt[d];
        }
    }
    cout<<ans<<endl;
}
0