結果
| 問題 | 
                            No.723 2つの数の和
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-08-30 00:22:19 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 49 ms / 2,000 ms | 
| コード長 | 939 bytes | 
| コンパイル時間 | 1,146 ms | 
| コンパイル使用メモリ | 100,328 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-13 19:43:27 | 
| 合計ジャッジ時間 | 3,312 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
int main() {
  int n, x;
  cin >> n >> x;
  vi a(n);
  rep(i, 0, n) cin >> a[i];
  sort(all(a));
  i64 ans = 0;
  rep(i, 0, n) {
    if(a[i] + *(lower_bound(all(a), x - a[i])) == x) {
      ans += (upper_bound(all(a), x - a[i]) - a.begin()) - (lower_bound(all(a), x - a[i]) - a.begin());
    }
  }
  cout << ans << endl;
}