結果

問題 No.723 2つの数の和
ユーザー MiyanagaTeruMiyanagaTeru
提出日時 2019-10-01 23:32:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,614 bytes
コンパイル時間 2,164 ms
コンパイル使用メモリ 204,804 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-26 19:15:53
合計ジャッジ時間 3,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 16 ms
4,380 KB
testcase_04 AC 23 ms
4,376 KB
testcase_05 AC 21 ms
4,376 KB
testcase_06 AC 22 ms
4,376 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 11 ms
4,380 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 22 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 18 ms
4,380 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 16 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 23 ms
4,380 KB
testcase_24 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

    ll N, X; cin >> N >> X;
    vel a(N); rep(i,N) cin >> a[i];
    sort(all(a));
    ll ans = 0; int id, id2;
    rep(i,N) {
        id = lower_bound(all(a), X - a[i]) - a.begin();
        id2 = upper_bound(all(a), X - a[i]) - a.begin();
        ans += id2 - id;
    }
    cout << ans << endl;
    return 0;
}
0