結果

問題 No.723 2つの数の和
ユーザー tadanoningen
提出日時 2021-09-06 00:11:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 193,348 KB
最終ジャッジ日時 2025-01-24 08:25:53
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n),cnt(100005,0);
    for(int i=0;i < n;i++) cin >> a[i];
    for(int i=0;i < n;i++) cnt[a[i]]++;
    ll ans = 0;

    for(int i=0;i < n;i++){
        int aj = x - a[i];
        if(aj >= 0 && aj <= 100000) ans += cnt[aj];
    }

    cout << ans << endl;
    return 0;
}
0