結果

問題 No.723 2つの数の和
ユーザー DaYuanChi
提出日時 2021-01-30 15:00:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 441 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 171,776 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 02:37:49
合計ジャッジ時間 3,449 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  int n, x; cin >> n >> x;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for(int i = 0; i < n; i++){
    int num = x - a[i];
    if(num < 0) break;
    ans += upper_bound(a.begin(), a.end(), num)
                - lower_bound(a.begin(), a.end(), num);
  }
  cout << ans << endl;
  return 0;
}
      
0